From 64b4de8b8ac68d86bd7447d7830ce6ce9b020a67 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 18 Aug 2026 00:44:55 +0300 Subject: [PATCH] chore: Format code --- internal/handlers/middleware.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/handlers/middleware.go b/internal/handlers/middleware.go index 3f75b25..6da88c1 100644 --- a/internal/handlers/middleware.go +++ b/internal/handlers/middleware.go @@ -9,15 +9,15 @@ import ( func LoggingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now() - + // Create a response writer wrapper to capture status code wrapper := &responseWriter{ResponseWriter: w, statusCode: http.StatusOK} - + next.ServeHTTP(wrapper, r) - + duration := time.Since(start) timestamp := time.Now().Format(time.RFC3339) - + log.Printf("[%s] %s %s - %d (%v)", timestamp, r.Method, r.URL.Path, wrapper.statusCode, duration) }) } @@ -32,12 +32,12 @@ func CORSMiddleware(next http.Handler) http.Handler { w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") w.Header().Set("Access-Control-Max-Age", "86400") - + if r.Method == http.MethodOptions { w.WriteHeader(http.StatusOK) return } - + next.ServeHTTP(w, r) }) } @@ -50,4 +50,4 @@ type responseWriter struct { func (rw *responseWriter) WriteHeader(code int) { rw.statusCode = code rw.ResponseWriter.WriteHeader(code) -} \ No newline at end of file +}