mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
23 lines
429 B
Go
23 lines
429 B
Go
package petstoreserver
|
|
|
|
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),
|
|
)
|
|
})
|
|
} |