Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError writes an error to the response as a JSON object. If the error is an instance of Error, the status code will be set to the error's code. Otherwise, it will return a 400 status code.
Types ¶
type Handler ¶
type Handler func(http.ResponseWriter, *http.Request) error
Handler is similar to http.HandlerFunc with simple error handling built in. If an error is returned, it will be written to the response as a JSON object (using WriteError).
type ResponseWriter ¶ added in v0.64.1
type ResponseWriter interface {
http.ResponseWriter
// Status returns the HTTP status of the request, or 0 if one has not
// yet been sent.
Status() int
// BytesWritten returns the total number of bytes sent to the client.
BytesWritten() int
}
ResponseWriter wraps an http.ResponseWriter with response metadata tracking.
func WrapResponseWriter ¶ added in v0.64.1
func WrapResponseWriter(w http.ResponseWriter, protoMajor int) ResponseWriter
WrapResponseWriter wraps an http.ResponseWriter with response metadata tracking.
Click to show internal directories.
Click to hide internal directories.