(w http.ResponseWriter, r *http.Request)
| 220 | } |
| 221 | |
| 222 | func (h *httpHandlers) handleData(w http.ResponseWriter, r *http.Request) { |
| 223 | defer func() { |
| 224 | panicErr := util.PanicHandler("handleData", recover()) |
| 225 | if panicErr != nil { |
| 226 | http.Error(w, fmt.Sprintf("internal server error: %v", panicErr), http.StatusInternalServerError) |
| 227 | } |
| 228 | }() |
| 229 | |
| 230 | setCORSHeaders(w, r) |
| 231 | setNoCacheHeaders(w) |
| 232 | |
| 233 | if r.Method == http.MethodOptions { |
| 234 | w.WriteHeader(http.StatusOK) |
| 235 | return |
| 236 | } |
| 237 | |
| 238 | if r.Method != http.MethodGet { |
| 239 | http.Error(w, "method not allowed", http.StatusMethodNotAllowed) |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | result := h.Client.Root.GetDataMap() |
| 244 | |
| 245 | w.Header().Set("Content-Type", "application/json") |
| 246 | if err := json.NewEncoder(w).Encode(result); err != nil { |
| 247 | log.Printf("failed to encode data response: %v", err) |
| 248 | http.Error(w, "failed to encode response", http.StatusInternalServerError) |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | func (h *httpHandlers) handleConfig(w http.ResponseWriter, r *http.Request) { |
| 253 | defer func() { |
nothing calls this directly
no test coverage detected