mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-06 16:57:29 +08:00
cron web api: use POST for create/update/delete actions
This commit is contained in:
@@ -361,7 +361,7 @@ func (s *RegistryServer) handleWebUICron(w http.ResponseWriter, r *http.Request)
|
|||||||
} else {
|
} else {
|
||||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "job": res})
|
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "job": res})
|
||||||
}
|
}
|
||||||
case http.MethodPost, http.MethodPut, http.MethodDelete:
|
case http.MethodPost:
|
||||||
args := map[string]interface{}{}
|
args := map[string]interface{}{}
|
||||||
if r.Body != nil {
|
if r.Body != nil {
|
||||||
_ = json.NewDecoder(r.Body).Decode(&args)
|
_ = json.NewDecoder(r.Body).Decode(&args)
|
||||||
@@ -369,17 +369,9 @@ func (s *RegistryServer) handleWebUICron(w http.ResponseWriter, r *http.Request)
|
|||||||
if id := strings.TrimSpace(r.URL.Query().Get("id")); id != "" {
|
if id := strings.TrimSpace(r.URL.Query().Get("id")); id != "" {
|
||||||
args["id"] = id
|
args["id"] = id
|
||||||
}
|
}
|
||||||
action := ""
|
action := "create"
|
||||||
switch r.Method {
|
if a, ok := args["action"].(string); ok && strings.TrimSpace(a) != "" {
|
||||||
case http.MethodPost:
|
action = strings.ToLower(strings.TrimSpace(a))
|
||||||
action = "create"
|
|
||||||
if a, ok := args["action"].(string); ok && strings.TrimSpace(a) != "" {
|
|
||||||
action = strings.ToLower(strings.TrimSpace(a))
|
|
||||||
}
|
|
||||||
case http.MethodPut:
|
|
||||||
action = "update"
|
|
||||||
case http.MethodDelete:
|
|
||||||
action = "delete"
|
|
||||||
}
|
}
|
||||||
res, err := s.onCron(action, args)
|
res, err := s.onCron(action, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user