more middleware
This commit is contained in:
parent
bedf6cb8e9
commit
177556399d
|
@ -8,6 +8,10 @@ import (
|
||||||
|
|
||||||
// Middleware is a slice of Middleware (aka func(n http.Handler) http.Handler {})
|
// Middleware is a slice of Middleware (aka func(n http.Handler) http.Handler {})
|
||||||
var Middleware []func(next http.Handler) http.Handler = []func(next http.Handler) http.Handler{
|
var Middleware []func(next http.Handler) http.Handler = []func(next http.Handler) http.Handler{
|
||||||
|
// chi's recommended list
|
||||||
|
middleware.RequestID,
|
||||||
|
middleware.RealIP,
|
||||||
|
// plus custom request logger
|
||||||
func(next http.Handler) http.Handler {
|
func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
app.Logger.Info("REQUEST", "url", r.URL, "ip", r.RemoteAddr, "useragent", r.UserAgent())
|
app.Logger.Info("REQUEST", "url", r.URL, "ip", r.RemoteAddr, "useragent", r.UserAgent())
|
||||||
|
|
Loading…
Reference in a new issue