(w http.ResponseWriter, r *http.Request)
| 361 | } |
| 362 | |
| 363 | func (h *httpHandlers) handleModalResult(w http.ResponseWriter, r *http.Request) { |
| 364 | defer func() { |
| 365 | panicErr := util.PanicHandler("handleModalResult", recover()) |
| 366 | if panicErr != nil { |
| 367 | http.Error(w, fmt.Sprintf("internal server error: %v", panicErr), http.StatusInternalServerError) |
| 368 | } |
| 369 | }() |
| 370 | |
| 371 | setNoCacheHeaders(w) |
| 372 | |
| 373 | if r.Method != http.MethodPost { |
| 374 | http.Error(w, "method not allowed", http.StatusMethodNotAllowed) |
| 375 | return |
| 376 | } |
| 377 | |
| 378 | body, err := io.ReadAll(r.Body) |
| 379 | if err != nil { |
| 380 | http.Error(w, fmt.Sprintf("failed to read request body: %v", err), http.StatusBadRequest) |
| 381 | return |
| 382 | } |
| 383 | |
| 384 | var result rpctypes.ModalResult |
| 385 | if err := json.Unmarshal(body, &result); err != nil { |
| 386 | http.Error(w, fmt.Sprintf("failed to parse JSON: %v", err), http.StatusBadRequest) |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | h.Client.CloseModal(result.ModalId, result.Confirm) |
| 391 | |
| 392 | w.Header().Set("Content-Type", "application/json") |
| 393 | w.WriteHeader(http.StatusOK) |
| 394 | json.NewEncoder(w).Encode(map[string]any{"success": true}) |
| 395 | } |
| 396 | |
| 397 | func (h *httpHandlers) handleTermInput(w http.ResponseWriter, r *http.Request) { |
| 398 | defer func() { |
nothing calls this directly
no test coverage detected