clear logs on contrl socket
This commit is contained in:
parent
1b08df0ce0
commit
eb66cb4307
1 changed files with 12 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
func setupHTTPCtl(hub circolog.Hub) *mux.Router {
|
||||
mux := mux.NewRouter()
|
||||
mux.HandleFunc("/pause/toggle", togglePause(hub)).Methods("POST")
|
||||
mux.HandleFunc("/logs/clear", clearQueue(hub)).Methods("POST")
|
||||
return mux
|
||||
}
|
||||
|
||||
|
@ -24,3 +25,14 @@ func togglePause(hub circolog.Hub) http.HandlerFunc {
|
|||
enc.Encode(map[string]interface{}{"paused": !active})
|
||||
}
|
||||
}
|
||||
|
||||
func clearQueue(hub circolog.Hub) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
hub.Commands <- circolog.HubFullCommand{Command: circolog.CommandClear}
|
||||
resp := <-hub.Responses
|
||||
success := resp.Value.(bool)
|
||||
w.Header().Set("content-type", "application/json")
|
||||
enc := json.NewEncoder(w)
|
||||
enc.Encode(map[string]interface{}{"success": success})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue