Skip to content

Rework SSERouter's StreamAdapter

Compare
Choose a tag to compare
@m110 m110 released this 05 Aug 12:11
· 27 commits to master since this release
a746d0b

Previously, GetResponse took http.ResponseWriter as an argument. Because of this, the client could attempt to write to the response while the request was already cancelled by the user.

The new approach uses two methods for getting the response.

  1. InitialStreamResponse used to initialize the stream. You can set HTTP status code and headers at this point.
  2. NextStreamResponse that verifies if the event should be sent (what Validate previously did) and returns the response.

Please see the tests for an example how the new adapter works.