This commit is contained in:
teddy
2025-04-18 18:15:59 +07:00
parent f7db944b97
commit d20ff0b41b
10 changed files with 306 additions and 92 deletions

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