ActivityPub/utils/logger.go

24 lines
343 B
Go
Raw Permalink Normal View History

2020-10-17 10:13:15 +00:00
package utils
import (
"log"
"net/http"
"time"
)
func APILogger(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\t%s\t%s\t%s",
r.Method,
r.RequestURI,
name,
time.Since(start),
)
})
}