Feat: better logs; login page

This commit is contained in:
Grail Finder
2025-05-02 10:54:51 +03:00
parent 043026de75
commit d18855cd49
6 changed files with 31 additions and 16 deletions

View File

@ -32,17 +32,13 @@ func (w *responseWriterWrapper) WriteHeader(status int) {
func LogRequests(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
log.Info("request started", "method", r.Method, "path", r.URL.Path)
// Wrap response writer to capture status code
ww := &responseWriterWrapper{ResponseWriter: w}
next.ServeHTTP(ww, r)
duration := time.Since(start)
log.Debug("request completed",
"method", r.Method,
"path", r.URL.Path,
log.Debug("request completed",
"method", r.Method,
"path", r.URL.Path,
"status", ww.status,
"duration", duration.String(),
)