22 lines
414 B
Go
22 lines
414 B
Go
package httphandlers
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"fiskerinc.com/modules/logger"
|
|
)
|
|
|
|
func LogRequest(next http.HandlerFunc) http.HandlerFunc {
|
|
wrapper := func(w http.ResponseWriter, r *http.Request) {
|
|
logger.Info().
|
|
Str("headers", fmt.Sprintf("%v", r.Header)).
|
|
Str("ip", r.RemoteAddr).
|
|
Str("user", GetClientID(r)).
|
|
Msgf("%s %s", r.Method, r.RequestURI)
|
|
next.ServeHTTP(w, r)
|
|
}
|
|
|
|
return wrapper
|
|
}
|