Script execution list

This commit is contained in:
Magnus Åhall 2025-08-08 18:15:13 +02:00
parent 13a5b9a973
commit 55724b36b5
8 changed files with 517 additions and 14 deletions

View file

@ -55,6 +55,8 @@ func initWebserver() (err error) {
http.HandleFunc("/hooks/update", actionHookUpdate)
http.HandleFunc("/hooks/delete/{hookID}", actionHookDelete)
http.HandleFunc("/hooks/schedule/{hookID}", actionHookSchedule)
http.HandleFunc("/scriptexecutions/", actionScriptExecutions)
http.HandleFunc("/scriptexecutions/{executionID}", actionScriptExecutionGet)
err = http.ListenAndServe(address, nil)
return
@ -752,4 +754,45 @@ func actionHookSchedule(w http.ResponseWriter, r *http.Request) { // {{{
w.Write(j)
} // }}}
func actionScriptExecutions(w http.ResponseWriter, r *http.Request) { // {{{
execs, err := GetScriptExecutions()
if err != nil {
err = werr.Wrap(err)
httpError(w, err)
return
}
out := struct {
OK bool
ScriptExecutions []ScriptExecutionBrief
}{
true,
execs,
}
j, _ := json.Marshal(out)
w.Write(j)
} // }}}
func actionScriptExecutionGet(w http.ResponseWriter, r *http.Request) { // {{{
executionID := 0
executionIDStr := r.PathValue("executionID")
executionID, _ = strconv.Atoi(executionIDStr)
execution, err := GetScriptExecution(executionID)
if err != nil {
err = werr.Wrap(err)
httpError(w, err)
return
}
out := struct {
OK bool
ScriptExecution ScriptExecution
}{
true,
execution,
}
j, _ := json.Marshal(out)
w.Write(j)
} // }}}
// vim: foldmethod=marker