Skip to content

Flush SSE responses through middleware wrappers - #19

Merged
donseba merged 2 commits into
mainfrom
feature/fix-sse-middleware-flush
Oct 3, 2026
Merged

donseba merged 2 commits into
mainfrom
feature/fix-sse-middleware-flush

Conversation

@donseba

@donseba donseba commented Oct 3, 2026

Copy link
Copy Markdown
Owner

This pull request refactors the Flush logic in the SSE writer to better support middleware wrappers and adds comprehensive tests for these behaviors. The main change is to use http.NewResponseController for flushing, which follows the Unwrap() chain and honors custom FlushError implementations, making the SSE writer more robust and middleware-friendly.

SSE Writer Flushing Improvements

  • Refactored the Writer struct in exp/sse/sse.go to remove the direct http.Flusher field and instead use http.NewResponseController(s.w).Flush() for flushing, ensuring compatibility with middleware wrappers and honoring FlushError methods. [1] [2] [3]
  • Updated the documentation in README.md to clarify that Flush now follows middleware wrappers and honors their FlushError methods.

Testing Enhancements

  • Added new tests in exp/sse/flush_test.go to verify that Flush works through middleware wrappers (using Unwrap()), honors FlushError implementations, and gracefully handles uninitialized writers.

Minor Documentation Cleanup

  • Removed an unnecessary trailing line from the end of the README.md for clarity.

@donseba
donseba merged commit a4ac547 into main Oct 3, 2026
1 check passed
@donseba
donseba deleted the feature/fix-sse-middleware-flush branch October 3, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant