update
This commit is contained in:
17
middleware/middleware.go
Normal file
17
middleware/middleware.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ResponseTimeMiddleware(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
path := r.URL.Path
|
||||
next(w, r)
|
||||
duration := time.Since(start)
|
||||
log.Printf("%+v response time %+v", path, duration)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user