MCPcopy Index your code
hub / github.com/tailscale/tailscale / writeJSON

Function writeJSON

client/web/web.go:1349–1356  ·  view source on GitHub ↗
(w http.ResponseWriter, data any)

Source from the content-addressed store, hash-verified

1347}
1348
1349func writeJSON(w http.ResponseWriter, data any) {
1350 w.Header().Set("Content-Type", "application/json")
1351 if err := json.NewEncoder(w).Encode(data); err != nil {
1352 w.Header().Set("Content-Type", "text/plain")
1353 http.Error(w, err.Error(), http.StatusInternalServerError)
1354 return
1355 }
1356}

Callers 6

serveAPIAuthMethod · 0.70
serveGetNodeDataMethod · 0.70
serveGetExitNodesMethod · 0.70
mockLocalAPIFunction · 0.70
TestServePostRoutesFunction · 0.70

Calls 4

EncodeMethod · 0.80
SetMethod · 0.65
ErrorMethod · 0.65
HeaderMethod · 0.45

Tested by 2

mockLocalAPIFunction · 0.56
TestServePostRoutesFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…