diff --git a/internal/api/server.go b/internal/api/server.go index 3defd92..3650583 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -184,9 +184,8 @@ func NewServer(api *store.Store, hub *events.Hub[store.Event], processQueue chan case <-ctx.Done(): w.WriteHeader(http.StatusRequestTimeout) case processQueue <- reference: + w.WriteHeader(http.StatusAccepted) } - - w.WriteHeader(http.StatusAccepted) }) s.mux.HandleFunc("GET /api/v1/feed.rss", func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/httputil/statusrecorder.go b/internal/httputil/statusrecorder.go index 62c9a95..611836e 100644 --- a/internal/httputil/statusrecorder.go +++ b/internal/httputil/statusrecorder.go @@ -5,6 +5,7 @@ import ( ) var _ http.ResponseWriter = (*StatusRecorder)(nil) +var _ http.Flusher = (*StatusRecorder)(nil) type StatusRecorder struct { Writer http.ResponseWriter @@ -12,6 +13,13 @@ type StatusRecorder struct { statusCode int } +// Flush implements http.Flusher. +func (s *StatusRecorder) Flush() { + if flusher, ok := s.Writer.(http.Flusher); ok { + flusher.Flush() + } +} + // Header implements http.ResponseWriter. func (s *StatusRecorder) Header() http.Header { return s.Writer.Header()