package middleware import ( "log" "net/http" "time" ) // LoggingMiddleware logs information about each HTTP request func LoggingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now() log.Printf("Started %s %s from %s", r.Method, r.URL.Path, r.RemoteAddr) next.ServeHTTP(w, r) log.Printf("Completed %s %s in %v", r.Method, r.URL.Path, time.Since(start)) }) }