Init: lab4 done

This commit is contained in:
2025-11-07 05:26:09 +08:00
commit b55f254d82
23 changed files with 1140 additions and 0 deletions

17
middlewares/accessLog.go Normal file
View 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)
}
}