All Downloads are FREE. Search and download functionalities are using the official Maven repository.

go-server.logger.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
{{>partial_header}}
package {{packageName}}

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),
		)
	})
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy