1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00

Глава 8

Допричесать игру
This commit is contained in:
Stanislav Chernyshev
2025-06-22 21:04:23 +03:00
parent b895709c86
commit d4e7211d1d
41 changed files with 1724 additions and 143 deletions

View File

@@ -0,0 +1,23 @@
package service
import (
"log"
"net/http"
"time"
)
func Logger(inner http.Handler, name string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
inner.ServeHTTP(w, r)
log.Printf(
"%s %s %s %s",
r.Method,
r.RequestURI,
name,
time.Since(start),
)
})
}