From e9b3e226b8feacd4b94c53f4b15ef7aabe67618e Mon Sep 17 00:00:00 2001 From: Matteo Suppo Date: Mon, 1 Feb 2016 11:43:13 +0100 Subject: [PATCH 1/3] Add version in info --- info.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/info.go b/info.go index 6fe3df038..3070995cd 100644 --- a/info.go +++ b/info.go @@ -6,9 +6,10 @@ import ( 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, }) } From 815fd78d53d1c49177a0026a3e20c1acfd03a2b4 Mon Sep 17 00:00:00 2001 From: Matteo Suppo Date: Mon, 1 Feb 2016 11:51:09 +0100 Subject: [PATCH 2/3] Add PauseHandler --- info.go | 18 ++++++++++++++++++ main.go | 1 + 2 files changed, 19 insertions(+) diff --git a/info.go b/info.go index 3070995cd..a205dc2bd 100644 --- a/info.go +++ b/info.go @@ -1,6 +1,10 @@ package main import ( + "log" + + "github.com/facchinm/go-serial" + "github.com/facchinm/systray" "github.com/gin-gonic/gin" ) @@ -13,3 +17,17 @@ func infoHandler(c *gin.Context) { "wss": "wss://localhost" + portSSL, }) } + +func pauseHandler(c *gin.Context) { + go func() { + ports, _ := serial.GetPortsList() + for _, element := range ports { + spClose(element) + } + systray.Quit() + *hibernate = true + log.Println("Restart becayse setup went wrong?") + 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 From e025b88520713e1069324be128ae4cdd8a258083 Mon Sep 17 00:00:00 2001 From: Matteo Suppo Date: Mon, 1 Feb 2016 11:58:21 +0100 Subject: [PATCH 3/3] Support linux_arm --- info.go | 3 --- info_linux_arm.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 info_linux_arm.go diff --git a/info.go b/info.go index a205dc2bd..47fba97b8 100644 --- a/info.go +++ b/info.go @@ -1,8 +1,6 @@ package main import ( - "log" - "github.com/facchinm/go-serial" "github.com/facchinm/systray" "github.com/gin-gonic/gin" @@ -26,7 +24,6 @@ func pauseHandler(c *gin.Context) { } systray.Quit() *hibernate = true - log.Println("Restart becayse setup went wrong?") 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) +}