MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / renderJSON

Function renderJSON

rest/oidc_api_test.go:238–246  ·  view source on GitHub ↗

renderJSON renders the response data as "application/json" with the status code. It may report status 500 Internal Server Error if there is any failure in converting the response data to JSON document.

(w http.ResponseWriter, r *http.Request, statusCode int, data interface{})

Source from the content-addressed store, hash-verified

236// It may report status 500 Internal Server Error if there is any failure in converting the
237// response data to JSON document.
238func renderJSON(w http.ResponseWriter, r *http.Request, statusCode int, data interface{}) {
239 w.Header().Set("Content-Type", "application/json")
240 w.WriteHeader(statusCode)
241 if err := json.NewEncoder(w).Encode(data); err != nil {
242 base.ErrorfCtx(r.Context(), "Error rendering JSON response: %s", err)
243 w.WriteHeader(http.StatusInternalServerError)
244 return
245 }
246}
247
248// authHandler mocks the authentication process performed by the OAuth Authorization Server.
249// The behavior of authHandler can be modified through the options map when needed.

Callers 3

discoveryHandlerMethod · 0.85
tokenHandlerMethod · 0.85
keysHandlerMethod · 0.85

Calls 6

ErrorfCtxFunction · 0.92
HeaderMethod · 0.80
EncodeMethod · 0.65
ContextMethod · 0.65
SetMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected