Files
vikunja-notifier/internal/services/core/httpserver/request_logger.go
T

25 lines
463 B
Go
Raw Normal View History

2026-06-10 10:23:00 +05:00
package httpserver
import (
"fmt"
"net/http"
"time"
)
func (h *httpServer) requestLoggingMiddleware(fn http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
startTime := time.Now()
fn(w, r)
h.logger.Info(
"HTTP request.",
"remote_addr", r.RemoteAddr,
"user_agent", r.UserAgent(),
"host", r.Host,
"path", fmt.Sprintf("%s %s", r.Method, r.RequestURI),
"duration", time.Since(startTime),
)
}
}