MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / JSON

Function JSON

pkg/webhandlers/error.go:148–156  ·  view source on GitHub ↗

JSON encodes the provided message as JSON. When a marshalling error is encountered, Error is used in order to handle the error.

(w http.ResponseWriter, r *http.Request, i any)

Source from the content-addressed store, hash-verified

146// JSON encodes the provided message as JSON. When a marshalling error
147// is encountered, Error is used in order to handle the error.
148func JSON(w http.ResponseWriter, r *http.Request, i any) {
149 b, err := json.Marshal(i)
150 if err != nil {
151 Error(w, r, err)
152 return
153 }
154 w.Header().Set("Content-Type", "application/json")
155 _, _ = w.Write(b)
156}

Callers 5

outputMethod · 0.92
handleGetGatewayMethod · 0.92
HandleLogoutMethod · 0.92
HandleTokenMethod · 0.92
CurrentUserMethod · 0.92

Calls 5

HeaderMethod · 0.80
ErrorFunction · 0.70
MarshalMethod · 0.65
SetMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected