Init: lab4 done
This commit is contained in:
17
middlewares/accessLog.go
Normal file
17
middlewares/accessLog.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/uptrace/bunrouter"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func AccessLog(next bunrouter.HandlerFunc) bunrouter.HandlerFunc {
|
||||
return func(w http.ResponseWriter, req bunrouter.Request) error {
|
||||
zap.L().Info("access",
|
||||
zap.String("method", req.Method),
|
||||
zap.String("route", req.Params().Route()))
|
||||
return next(w, req)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user