MCPcopy Create free account
hub / github.com/DoNewsCode/core / EncodeResponse

Method EncodeResponse

srvhttp/encode.go:59–61  ·  view source on GitHub ↗

EncodeResponse encodes an response value. If the response is not a StatusCoder, the http.StatusInternalServerError will be used.

(response interface{})

Source from the content-addressed store, hash-verified

57// EncodeResponse encodes an response value.
58// If the response is not a StatusCoder, the http.StatusInternalServerError will be used.
59func (s *ResponseEncoder) EncodeResponse(response interface{}) {
60 encode(s.w, response, http.StatusOK)
61}
62
63func encode(w http.ResponseWriter, any interface{}, code int) {
64 const contentType = "application/json; charset=utf-8"

Callers 2

EncodeMethod · 0.95

Calls 1

encodeFunction · 0.85

Tested by 1