Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
add minitouch reset
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Mar 2, 2019
1 parent 983fbed commit 282b896
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions minitouch.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func drainTouchRequests(conn net.Conn, reqC chan TouchRequest) error {
for req := range reqC {
var err error
switch req.Operation {
case "r": // reset
_, err = conn.Write([]byte("r\n"))
case "d":
fallthrough
case "m":
Expand Down
15 changes: 10 additions & 5 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,23 @@ func (server *Server) initHTTPServer() {
json.NewEncoder(w).Encode(state)
}).Methods("GET")

m.HandleFunc("/packages/{pkgname}/info", func(w http.ResponseWriter, r *http.Request){
m.HandleFunc("/packages/{pkgname}/info", func(w http.ResponseWriter, r *http.Request) {
pkgname := mux.Vars(r)["pkgname"]
info, err := pkgInfo(pkgname)
if err != nil {
renderJSON(w, map[string]interface{}{
"success": false,
"description": err.Error(),// "package " + strconv.Quote(pkgname) + " not found",
"success": false,
"description": err.Error(), // "package " + strconv.Quote(pkgname) + " not found",
})
return
}
renderJSON(w, map[string]interface{}{
"success": true,
"data": info,
"data": info,
})
})

m.HandleFunc("/packages/{pkgname}/icon", func(w http.ResponseWriter, r *http.Request){
m.HandleFunc("/packages/{pkgname}/icon", func(w http.ResponseWriter, r *http.Request) {
pkgname := mux.Vars(r)["pkgname"]
info, err := pkgInfo(pkgname)
if err != nil {
Expand Down Expand Up @@ -667,6 +667,11 @@ func (server *Server) initHTTPServer() {
}
}).Methods("PUT")

m.HandleFunc("/minitouch", func(w http.ResponseWriter, r *http.Request) {
service.Stop("minitouch", true)
io.WriteString(w, "minitouch stopped")
}).Methods("DELETE")

m.HandleFunc("/minitouch", singleFightNewerWebsocket(func(w http.ResponseWriter, r *http.Request, ws *websocket.Conn) {
defer ws.Close()
const wsWriteWait = 10 * time.Second
Expand Down

0 comments on commit 282b896

Please sign in to comment.