(w http.ResponseWriter, r *http.Request)
| 395 | } |
| 396 | |
| 397 | func (h *httpHandlers) handleTermInput(w http.ResponseWriter, r *http.Request) { |
| 398 | defer func() { |
| 399 | panicErr := util.PanicHandler("handleTermInput", recover()) |
| 400 | if panicErr != nil { |
| 401 | http.Error(w, fmt.Sprintf("internal server error: %v", panicErr), http.StatusInternalServerError) |
| 402 | } |
| 403 | }() |
| 404 | |
| 405 | setNoCacheHeaders(w) |
| 406 | |
| 407 | if r.Method != http.MethodPost { |
| 408 | http.Error(w, "method not allowed", http.StatusMethodNotAllowed) |
| 409 | return |
| 410 | } |
| 411 | |
| 412 | body, err := io.ReadAll(r.Body) |
| 413 | if err != nil { |
| 414 | http.Error(w, fmt.Sprintf("failed to read request body: %v", err), http.StatusBadRequest) |
| 415 | return |
| 416 | } |
| 417 | |
| 418 | var event vdom.VDomEvent |
| 419 | if err := json.Unmarshal(body, &event); err != nil { |
| 420 | http.Error(w, fmt.Sprintf("failed to parse JSON: %v", err), http.StatusBadRequest) |
| 421 | return |
| 422 | } |
| 423 | if strings.TrimSpace(event.WaveId) == "" { |
| 424 | http.Error(w, "waveid is required", http.StatusBadRequest) |
| 425 | return |
| 426 | } |
| 427 | if event.TermInput == nil { |
| 428 | http.Error(w, "terminput is required", http.StatusBadRequest) |
| 429 | return |
| 430 | } |
| 431 | |
| 432 | h.renderLock.Lock() |
| 433 | h.Client.Root.Event(event, h.Client.GlobalEventHandler) |
| 434 | h.renderLock.Unlock() |
| 435 | |
| 436 | w.WriteHeader(http.StatusNoContent) |
| 437 | } |
| 438 | |
| 439 | func (h *httpHandlers) handleDynContent(w http.ResponseWriter, r *http.Request) { |
| 440 | defer func() { |
nothing calls this directly
no test coverage detected