implement enable disable with client side display and mod
This commit is contained in:
32
server/delete.go
Normal file
32
server/delete.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"local/firestormy/config"
|
||||
"local/firestormy/config/ns"
|
||||
"local/firestormy/scheduler"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) delete(w http.ResponseWriter, r *http.Request) {
|
||||
keys := strings.Split(r.URL.Path, "/")
|
||||
key := keys[len(keys)-1]
|
||||
|
||||
j := &scheduler.Job{}
|
||||
b, err := config.Store.Get(key, ns.Jobs...)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if err := j.Decode(b); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if err := scheduler.Schedule.Remove(j); err != nil {
|
||||
if err := j.Decode(b); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
w.Write([]byte("{}"))
|
||||
}
|
||||
Reference in New Issue
Block a user