MCPcopy Index your code
hub / github.com/dnote/dnote / respondJSON

Function respondJSON

pkg/server/controllers/helpers.go:291–302  ·  view source on GitHub ↗

respondJSON encodes the given payload into a JSON format and writes it to the given response writer

(w http.ResponseWriter, statusCode int, payload interface{})

Source from the content-addressed store, hash-verified

289
290// respondJSON encodes the given payload into a JSON format and writes it to the given response writer
291func respondJSON(w http.ResponseWriter, statusCode int, payload interface{}) {
292 w.Header().Set("Content-Type", "application/json")
293
294 dat, err := json.Marshal(payload)
295 if err != nil {
296 handleJSONError(w, err, "encoding response")
297 return
298 }
299
300 w.WriteHeader(statusCode)
301 w.Write(dat)
302}
303
304func getClientType(r *http.Request) string {
305 origin := r.Header.Get("Origin")

Callers 12

V3IndexMethod · 0.85
V3ShowMethod · 0.85
V3CreateMethod · 0.85
V3UpdateMethod · 0.85
V3DeleteMethod · 0.85
V3IndexMethod · 0.85
V3ShowMethod · 0.85
V3CreateMethod · 0.85
V3DeleteMethod · 0.85
V3UpdateMethod · 0.85
GetSyncFragmentMethod · 0.85
GetSyncStateMethod · 0.85

Calls 2

handleJSONErrorFunction · 0.85
WriteHeaderMethod · 0.80

Tested by

no test coverage detected