MCPcopy Create free account
hub / github.com/daodst/chat / writeHTTPMessage

Function writeHTTPMessage

clientapi/routing/auth_fallback.go:199–211  ·  view source on GitHub ↗

writeHTTPMessage writes the given header and message to the HTTP response writer. Returns an error JSONResponse obtained through httputil.LogThenError if the writing failed, otherwise nil.

(
	w http.ResponseWriter, req *http.Request,
	message string, header int,
)

Source from the content-addressed store, hash-verified

197// writeHTTPMessage writes the given header and message to the HTTP response writer.
198// Returns an error JSONResponse obtained through httputil.LogThenError if the writing failed, otherwise nil.
199func writeHTTPMessage(
200 w http.ResponseWriter, req *http.Request,
201 message string, header int,
202) *util.JSONResponse {
203 w.WriteHeader(header)
204 _, err := w.Write([]byte(message))
205 if err != nil {
206 util.GetLogger(req.Context()).WithError(err).Error("w.Write failed")
207 res := jsonerror.InternalServerError()
208 return &res
209 }
210 return nil
211}

Callers 2

AuthFallbackFunction · 0.85
checkRecaptchaEnabledFunction · 0.85

Calls 3

WriteMethod · 0.80
ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected