MCPcopy Create free account
hub / github.com/krau/SaveAny-Bot / loggingMiddleware

Function loggingMiddleware

api/server.go:114–125  ·  view source on GitHub ↗

loggingMiddleware 日志中间件

(next http.Handler)

Source from the content-addressed store, hash-verified

112
113// loggingMiddleware 日志中间件
114func loggingMiddleware(next http.Handler) http.Handler {
115 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
116 start := time.Now()
117
118 // 包装 ResponseWriter 以获取状态码
119 wrapped := &responseWriter{ResponseWriter: w, statusCode: http.StatusOK}
120
121 next.ServeHTTP(wrapped, r)
122
123 log.Infof("%s %s %d %s", r.Method, r.URL.Path, wrapped.statusCode, time.Since(start))
124 })
125}
126
127// recoveryMiddleware 恢复中间件
128func recoveryMiddleware(next http.Handler) http.Handler {

Callers 1

NewServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected