Files
links.stevanfreeborn.com/internal/middleware/main.go
T

17 lines
369 B
Go
Raw Normal View History

// Package middleware provides HTTP middleware for the web application.
package middleware
import (
"log"
"net/http"
"time"
)
func Logging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
next.ServeHTTP(w, r)
log.Printf("%s %s %s", r.Method, r.RequestURI, time.Since(start))
})
}