Documentation ¶
Overview ¶
Package httplog provides logging for http requests.
Index ¶
- func ApacheCombinedFormat(l *log.Logger) httpmux.MiddlewareFunc
- func ApacheCommonFormat(l *log.Logger) httpmux.MiddlewareFunc
- func DefaultFormat(l *log.Logger) httpmux.MiddlewareFunc
- func Error(r *http.Request, v ...interface{})
- func Errorf(r *http.Request, format string, v ...interface{})
- func Errorln(r *http.Request, v ...interface{})
- func UseXForwardedFor(next http.HandlerFunc) http.HandlerFunc
- type ErrorType
- type ResponseRecorder
- type ResponseWriter
- func (w *ResponseWriter) Bytes() int
- func (w *ResponseWriter) CloseNotify() <-chan bool
- func (w *ResponseWriter) Code() int
- func (w *ResponseWriter) Flush()
- func (w *ResponseWriter) Header() http.Header
- func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *ResponseWriter) Write(b []byte) (int, error)
- func (w *ResponseWriter) WriteHeader(code int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApacheCombinedFormat ¶
func ApacheCombinedFormat(l *log.Logger) httpmux.MiddlewareFunc
ApacheCombinedFormat returns a middleware that logs http requests to the given logger using the Apache Combined log format.
func ApacheCommonFormat ¶
func ApacheCommonFormat(l *log.Logger) httpmux.MiddlewareFunc
ApacheCommonFormat returns a middleware that logs http requests to the given logger using the Apache Common log format.
func DefaultFormat ¶
func DefaultFormat(l *log.Logger) httpmux.MiddlewareFunc
DefaultFormat returns a middleware that logs http requests to the given logger using the default log format.
func UseXForwardedFor ¶
func UseXForwardedFor(next http.HandlerFunc) http.HandlerFunc
UseXForwardedFor parses the first value from the X-Forwarded-For header and updates the request RemoteAddr field with it, then call the next handler and reverts the value back at the end.
Types ¶
type ErrorType ¶
type ErrorType int
ErrorType is the type used for storing error in a context.Context.
var ErrorID ErrorType
ErrorID is the key used for storing and retrieving errors to/from context.
type ResponseRecorder ¶
type ResponseRecorder interface { Code() int // Response status code Bytes() int // Bytes written to the client }
The ResponseRecorder interface is implemented by ResponseWriters that can record the response status code and bytes written to the client.
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter http.Hijacker http.Flusher http.CloseNotifier ResponseRecorder // contains filtered or unexported fields }
ResponseWriter is an http.ResponseWriter + ResponseRecorder.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
NewResponseWriter creates and initializes a new ResponseWriter.
func (*ResponseWriter) Bytes ¶
func (w *ResponseWriter) Bytes() int
Bytes implements the ResponseRecorder interface.
func (*ResponseWriter) CloseNotify ¶
func (w *ResponseWriter) CloseNotify() <-chan bool
CloseNotify implements the http.CloseNotififer interface.
func (*ResponseWriter) Code ¶
func (w *ResponseWriter) Code() int
Code implements the ResponseRecorder interface.
func (*ResponseWriter) Flush ¶
func (w *ResponseWriter) Flush()
Flush implements the http.Flusher interface.
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
Header implements the http.ResponseWriter interface.
func (*ResponseWriter) Hijack ¶
func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack implements the http.Hijacker interface.
func (*ResponseWriter) Write ¶
func (w *ResponseWriter) Write(b []byte) (int, error)
Write implements the http.ResponseWriter interface.
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(code int)
WriteHeader implements the http.ResponseWriter interface.