Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPMiddleware ¶
type HTTPMiddleware struct {
// contains filtered or unexported fields
}
HTTPMiddleware uses the Logger to implement basic structured request logging.
func NewHTTPMiddleware ¶
func NewHTTPMiddleware(next http.Handler, logger log.Logger) *HTTPMiddleware
NewHTTPMiddleware wraps an http.Handler and a log.Logger, and performs structured request logging.
func (*HTTPMiddleware) ServeHTTP ¶
func (mw *HTTPMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger satisfies log.Logger and is designed to be constructed into a context via New. Components can retrieve it from the context via From, and use the Log method to append keyvals. The entrypoint (e.g. an http.Handler) should Flush at the end of its lifecycle (e.g. the end of the request).
func New ¶
New is a helper function to create a new Logger, log the initial set of keyvals, inject it into a context, and return everything, all in one motion.