| 131 | } |
| 132 | |
| 133 | func (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 | |
| 154 | func (h *Handler) eval(w http.ResponseWriter, r *http.Request) { |
| 155 | // Read the body |