MCPcopy
hub / github.com/wavetermdev/waveterm / handleData

Method handleData

tsunami/engine/serverhandlers.go:222–250  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

220}
221
222func (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
252func (h *httpHandlers) handleConfig(w http.ResponseWriter, r *http.Request) {
253 defer func() {

Callers

nothing calls this directly

Calls 8

PanicHandlerFunction · 0.92
setCORSHeadersFunction · 0.85
setNoCacheHeadersFunction · 0.85
GetDataMapMethod · 0.80
ErrorMethod · 0.45
WriteHeaderMethod · 0.45
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected