(w http.ResponseWriter, r *http.Request)
| 325 | } |
| 326 | |
| 327 | func (h *httpHandlers) handleSchemas(w http.ResponseWriter, r *http.Request) { |
| 328 | defer func() { |
| 329 | panicErr := util.PanicHandler("handleSchemas", recover()) |
| 330 | if panicErr != nil { |
| 331 | http.Error(w, fmt.Sprintf("internal server error: %v", panicErr), http.StatusInternalServerError) |
| 332 | } |
| 333 | }() |
| 334 | |
| 335 | setCORSHeaders(w, r) |
| 336 | setNoCacheHeaders(w) |
| 337 | |
| 338 | if r.Method == http.MethodOptions { |
| 339 | w.WriteHeader(http.StatusOK) |
| 340 | return |
| 341 | } |
| 342 | |
| 343 | if r.Method != http.MethodGet { |
| 344 | http.Error(w, "method not allowed", http.StatusMethodNotAllowed) |
| 345 | return |
| 346 | } |
| 347 | |
| 348 | configSchema := GenerateConfigSchema(h.Client.Root) |
| 349 | dataSchema := GenerateDataSchema(h.Client.Root) |
| 350 | |
| 351 | result := map[string]any{ |
| 352 | "config": configSchema, |
| 353 | "data": dataSchema, |
| 354 | } |
| 355 | |
| 356 | w.Header().Set("Content-Type", "application/json") |
| 357 | if err := json.NewEncoder(w).Encode(result); err != nil { |
| 358 | log.Printf("failed to encode schemas response: %v", err) |
| 359 | http.Error(w, "failed to encode response", http.StatusInternalServerError) |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | func (h *httpHandlers) handleModalResult(w http.ResponseWriter, r *http.Request) { |
| 364 | defer func() { |
nothing calls this directly
no test coverage detected