organize middleware a little more.

This commit is contained in:
fiatjaf
2024-09-26 07:24:46 -03:00
parent 8b357b905e
commit 5a6cfd8975
4 changed files with 40 additions and 35 deletions

15
main.go
View File

@@ -38,21 +38,6 @@ var (
tailwindDebugStuff template.HTML
)
func loggingMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fullURL := fmt.Sprintf("%s://%s%s", r.Proto, r.Host, r.URL.Path)
if r.URL.RawQuery != "" {
fullURL += "?" + r.URL.RawQuery
}
log.Debug().Str("Full URL:", fullURL).Msg("Request URL => ")
log.Debug().Str("ip", r.Header.Get("X-Forwarded-For")).
Str("user-agent", r.Header.Get("User-Agent")).Str("referer", r.Header.Get("Referer")).Msg("Request details => ")
// Call the next handler in the chain
next.ServeHTTP(w, r)
})
}
func main() {
err := envconfig.Process("", &s)
if err != nil {