Skip to content

Commit

Permalink
Fix events not flushing with telemetry handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGustafsson committed Jan 14, 2025
1 parent 8b4fcc0 commit 8c39822
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions internal/httputil/statusrecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import (
)

var _ http.ResponseWriter = (*StatusRecorder)(nil)
var _ http.Flusher = (*StatusRecorder)(nil)

type StatusRecorder struct {
Writer http.ResponseWriter

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()
Expand Down

0 comments on commit 8c39822

Please sign in to comment.