Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log ¶
func Log(h http.Handler) http.HandlerFunc
Log returns a middleware that injects a logger into the request context. It uses the trace from the context as a prefix, if it exists.
func RecordResponse ¶
func RecordResponse(h http.Handler) http.HandlerFunc
RecordResponse returns a middleware that records the response status code and total bytes written to the response.
Types ¶
type RecordingResponseWriter ¶
type RecordingResponseWriter struct { // underlying response writer RW http.ResponseWriter StatusCode int // first status code written to the response writer Bytes int // total bytes written }
RecordingResponseWriter is an http.ResponseWriter that keeps track of the status code and total body bytes written to it
func (*RecordingResponseWriter) Header ¶
func (w *RecordingResponseWriter) Header() http.Header
Header just returns the underlying response writer's header.
func (*RecordingResponseWriter) Write ¶
func (w *RecordingResponseWriter) Write(b []byte) (int, error)
Write writes the given bytes to the undelying response writer, setting the status code to 200 if it hasn't been set already.
func (*RecordingResponseWriter) WriteHeader ¶
func (w *RecordingResponseWriter) WriteHeader(statusCode int)
WriteHeader sets the status code, if it hasn't been set already.
Click to show internal directories.
Click to hide internal directories.