Fix: sse changes
This commit is contained in:
		| @@ -11,29 +11,16 @@ import ( | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // responseWriterWrapper wraps http.ResponseWriter to capture status code | ||||
| type responseWriterWrapper struct { | ||||
| 	http.ResponseWriter | ||||
| 	status int | ||||
| } | ||||
|  | ||||
| func (w *responseWriterWrapper) WriteHeader(status int) { | ||||
| 	w.status = status | ||||
| 	w.ResponseWriter.WriteHeader(status) | ||||
| } | ||||
|  | ||||
| // LogRequests logs all HTTP requests with method, path and duration | ||||
| func LogRequests(next http.Handler) http.Handler { | ||||
| 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
| 		start := time.Now() | ||||
| 		// Wrap response writer to capture status code | ||||
| 		ww := &responseWriterWrapper{ResponseWriter: w} | ||||
| 		next.ServeHTTP(ww, r) | ||||
| 		next.ServeHTTP(w, r) | ||||
| 		duration := time.Since(start) | ||||
| 		log.Debug("request completed", | ||||
| 			"method", r.Method, | ||||
| 			"path", r.URL.RequestURI(), | ||||
| 			"status", ww.status, | ||||
| 			"duration", duration.String(), | ||||
| 		) | ||||
| 	}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder