Search for scripts
This commit is contained in:
parent
83f858285f
commit
38eef01e34
2 changed files with 68 additions and 10 deletions
30
webserver.go
30
webserver.go
|
|
@ -50,6 +50,7 @@ func initWebserver() (err error) {
|
|||
http.HandleFunc("/scripts/", actionScripts)
|
||||
http.HandleFunc("/scripts/update/{scriptID}", actionScriptUpdate)
|
||||
http.HandleFunc("/scripts/delete/{scriptID}", actionScriptDelete)
|
||||
http.HandleFunc("/hooks/search", actionScriptsSearch)
|
||||
http.HandleFunc("/hooks/update", actionHookUpdate)
|
||||
http.HandleFunc("/hooks/delete/{hookID}", actionHookDelete)
|
||||
|
||||
|
|
@ -622,6 +623,35 @@ func actionScriptDelete(w http.ResponseWriter, r *http.Request) { // {{{
|
|||
j, _ := json.Marshal(out)
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
func actionScriptsSearch(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var search struct {
|
||||
Search string
|
||||
}
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
err := json.Unmarshal(body, &search)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
scripts, err := SearchScripts(search.Search)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
httpError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
out := struct {
|
||||
OK bool
|
||||
Scripts []Script
|
||||
}{
|
||||
true,
|
||||
scripts,
|
||||
}
|
||||
j, _ := json.Marshal(out)
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
|
||||
func actionHookUpdate(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var hook Hook
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue