Documentation ¶
Index ¶
Constants ¶
View Source
const EntryKey key = 0
EntryKey is the context key for the logrus.Entry.
It use a private struct in order to avoid any conflict with other packages. Its value of zero is arbitrary.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware used to log the requests with a level based on the HTTP response status.
It is also possible to add an error with the LogError method with the request context.
The levels are: - 2XX => INFO - 3XX / 4XX => WARNING - 5XX => ERROR
func NewMiddleware ¶
func NewMiddleware(level string, options ...Option) *Middleware
NewMiddleware instantiate a new Middleware.
func (*Middleware) ServeHTTP ¶
func (t *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP serve the request then call the next middleware.
func (*Middleware) Wrap ¶
func (t *Middleware) Wrap(handler http.HandlerFunc) http.Handler
Wrap a classic http handler.
Click to show internal directories.
Click to hide internal directories.