Reload job in ui
This commit is contained in:
28
server/get.go
Normal file
28
server/get.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"local/firestormy/config"
|
||||
"local/firestormy/config/ns"
|
||||
"local/firestormy/scheduler"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) get(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
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(toMap(j))
|
||||
}
|
||||
Reference in New Issue
Block a user