MCPcopy
hub / github.com/labstack/echo / WriteHeader

Method WriteHeader

response.go:49–60  ·  view source on GitHub ↗

WriteHeader sends an HTTP response header with status code. If WriteHeader is not called explicitly, the first call to Write will trigger an implicit WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly used to send error codes.

(code int)

Source from the content-addressed store, hash-verified

47// WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly
48// used to send error codes.
49func (r *Response) WriteHeader(code int) {
50 if r.Committed {
51 r.logger.Error("echo: response already written to client")
52 return
53 }
54 r.Status = code
55 for _, fn := range r.beforeFuncs {
56 fn()
57 }
58 r.ResponseWriter.WriteHeader(r.Status)
59 r.Committed = true
60}
61
62// Write writes the data to the connection as part of an HTTP reply.
63func (r *Response) Write(b []byte) (n int, err error) {

Callers 13

WriteMethod · 0.95
TestEchoWrapHandlerFunction · 0.45
jsonPBlobMethod · 0.45
JSONPBlobMethod · 0.45
xmlMethod · 0.45
XMLBlobMethod · 0.45
BlobMethod · 0.45
StreamMethod · 0.45
NoContentMethod · 0.45
RedirectMethod · 0.45
WriteHeaderMethod · 0.45

Calls 1

ErrorMethod · 0.45

Tested by 2

TestEchoWrapHandlerFunction · 0.36