mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
21 lines
453 B
Go
21 lines
453 B
Go
package main
|
|
|
|
import "net/http"
|
|
|
|
func loggingMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
path := r.URL.Path
|
|
if r.URL.RawQuery != "" {
|
|
path += "?" + r.URL.RawQuery
|
|
}
|
|
log.Debug().
|
|
Str("ip", actualIP(r)).
|
|
Str("path", path).
|
|
Str("user-agent", r.Header.Get("User-Agent")).
|
|
Str("referer", r.Header.Get("Referer")).
|
|
Msg("request")
|
|
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|