Commit 8fe756bb authored by Mikhail Kotelnikov's avatar Mikhail Kotelnikov
Browse files

+ /uptime

parent 61900342
......@@ -6,6 +6,7 @@ import (
"github.com/gin-gonic/gin"
"time"
"net/http"
"os/exec"
)
var cfg Cfg
......@@ -57,6 +58,18 @@ func setupRouter() *gin.Engine {
return
}
if token == "uptime" {
cmd := exec.Command("uptime")
result, error := cmd.Output()
if error != nil {
log.Println("Command returned error: ", error)
c.AbortWithStatus(http.StatusInternalServerError)
return
}
c.String(200, string(result))
return
}
user, ok := cfg.Auth[token]
if ok {
log.Println("User", user, "requested the door opening")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment