Rework SSERouter's StreamAdapter
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.
InitialStreamResponse
used to initialize the stream. You can set HTTP status code and headers at this point.NextStreamResponse
that verifies if the event should be sent (whatValidate
previously did) and returns the response.
Please see the tests for an example how the new adapter works.