Schedule script run

This commit is contained in:
Magnus Åhall 2025-08-07 23:26:15 +02:00
parent fc992b8bdc
commit 6d05152ab2
6 changed files with 162 additions and 7 deletions

View file

@ -54,6 +54,7 @@ func initWebserver() (err error) {
http.HandleFunc("/hooks/search", actionScriptsSearch)
http.HandleFunc("/hooks/update", actionHookUpdate)
http.HandleFunc("/hooks/delete/{hookID}", actionHookDelete)
http.HandleFunc("/hooks/schedule/{hookID}", actionHookSchedule)
err = http.ListenAndServe(address, nil)
return
@ -730,5 +731,25 @@ func actionHookDelete(w http.ResponseWriter, r *http.Request) { // {{{
j, _ := json.Marshal(out)
w.Write(j)
} // }}}
func actionHookSchedule(w http.ResponseWriter, r *http.Request) { // {{{
hookID := 0
hookIDStr := r.PathValue("hookID")
hookID, _ = strconv.Atoi(hookIDStr)
err := ScheduleHook(hookID)
if err != nil {
err = werr.Wrap(err)
httpError(w, err)
return
}
out := struct {
OK bool
}{
true,
}
j, _ := json.Marshal(out)
w.Write(j)
} // }}}
// vim: foldmethod=marker