diff --git a/info.go b/info.go index 6fe3df038..47fba97b8 100644 --- a/info.go +++ b/info.go @@ -1,14 +1,30 @@ package main import ( + "github.com/facchinm/go-serial" + "github.com/facchinm/systray" "github.com/gin-gonic/gin" ) func infoHandler(c *gin.Context) { c.JSON(200, gin.H{ - "http": "http://localhost" + port, - "https": "https://localhost" + portSSL, - "ws": "ws://localhost" + port, - "wss": "wss://localhost" + portSSL, + "version": version, + "http": "http://localhost" + port, + "https": "https://localhost" + portSSL, + "ws": "ws://localhost" + port, + "wss": "wss://localhost" + portSSL, }) } + +func pauseHandler(c *gin.Context) { + go func() { + ports, _ := serial.GetPortsList() + for _, element := range ports { + spClose(element) + } + systray.Quit() + *hibernate = true + restart("") + }() + c.JSON(200, nil) +} diff --git a/info_linux_arm.go b/info_linux_arm.go new file mode 100644 index 000000000..96276534e --- /dev/null +++ b/info_linux_arm.go @@ -0,0 +1,28 @@ +package main + +import ( + "github.com/facchinm/go-serial" + "github.com/gin-gonic/gin" +) + +func infoHandler(c *gin.Context) { + c.JSON(200, gin.H{ + "version": version, + "http": "http://localhost" + port, + "https": "https://localhost" + portSSL, + "ws": "ws://localhost" + port, + "wss": "wss://localhost" + portSSL, + }) +} + +func pauseHandler(c *gin.Context) { + go func() { + ports, _ := serial.GetPortsList() + for _, element := range ports { + spClose(element) + } + *hibernate = true + restart("") + }() + c.JSON(200, nil) +} diff --git a/main.go b/main.go index 160319a3e..7cd153a6f 100755 --- a/main.go +++ b/main.go @@ -242,6 +242,7 @@ func main() { r.Handle("WSS", "/socket.io/", socketHandler) r.GET("/info", infoHandler) r.POST("/killbrowser", killBrowserHandler) + r.POST("/pause", pauseHandler) go func() { // check if certificates exist; if not, use plain http