databag/net/server/internal/logger.go

33 lines
757 B
Go
Raw Normal View History

2022-01-11 06:20:32 +00:00
/*
* DataBag
*
* DataBag provides storage for decentralized identity based self-hosting apps. It is intended to support sharing of personal data and hosting group conversations.
*
* API version: 0.0.1
* Contact: roland.osborne@gmail.com
2022-01-13 05:00:52 +00:00
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
2022-01-11 06:20:32 +00:00
*/
package databag
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),
)
})
}