Rendering and unhooking of hooks
This commit is contained in:
parent
2a04cba42a
commit
83f858285f
4 changed files with 122 additions and 24 deletions
32
webserver.go
32
webserver.go
|
|
@ -50,7 +50,8 @@ func initWebserver() (err error) {
|
|||
http.HandleFunc("/scripts/", actionScripts)
|
||||
http.HandleFunc("/scripts/update/{scriptID}", actionScriptUpdate)
|
||||
http.HandleFunc("/scripts/delete/{scriptID}", actionScriptDelete)
|
||||
http.HandleFunc("/hooks/update/{hookID}", actionHookUpdate)
|
||||
http.HandleFunc("/hooks/update", actionHookUpdate)
|
||||
http.HandleFunc("/hooks/delete/{hookID}", actionHookDelete)
|
||||
|
||||
err = http.ListenAndServe(address, nil)
|
||||
return
|
||||
|
|
@ -623,13 +624,36 @@ func actionScriptDelete(w http.ResponseWriter, r *http.Request) { // {{{
|
|||
} // }}}
|
||||
|
||||
func actionHookUpdate(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var hook Hook
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
err := json.Unmarshal(body, &hook)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = UpdateHook(hook)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
out := struct {
|
||||
OK bool
|
||||
}{
|
||||
true,
|
||||
}
|
||||
j, _ := json.Marshal(out)
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
func actionHookDelete(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
hookID := 0
|
||||
hookIDStr := r.PathValue("hookID")
|
||||
hookID, _ = strconv.Atoi(hookIDStr)
|
||||
|
||||
// XXX - here
|
||||
|
||||
err := UpdateHook(hook)
|
||||
err := DeleteHook(hookID)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue