MCPcopy
hub / github.com/livebud/bud / script

Method script

package/budhttp/budsvr/handler.go:133–152  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

131}
132
133func (h *Handler) script(w http.ResponseWriter, r *http.Request) {
134 // Read the body
135 body, err := io.ReadAll(r.Body)
136 if err != nil {
137 http.Error(w, err.Error(), http.StatusBadRequest)
138 return
139 }
140 // Unmarshal the request body into an event
141 var script budhttp.Script
142 if err := json.Unmarshal(body, &script); err != nil {
143 http.Error(w, err.Error(), http.StatusBadRequest)
144 return
145 }
146 if err := h.vm.Script(script.Path, script.Script); err != nil {
147 http.Error(w, err.Error(), http.StatusInternalServerError)
148 return
149 }
150 // Return a No Content response
151 w.WriteHeader(http.StatusNoContent)
152}
153
154func (h *Handler) eval(w http.ResponseWriter, r *http.Request) {
155 // Read the body

Callers

nothing calls this directly

Calls 3

UnmarshalMethod · 0.80
ErrorMethod · 0.65
ScriptMethod · 0.65

Tested by

no test coverage detected