Context to be passed to the
HttpServer.sse(String, Consumer, Consumer)'s second parameter, when an SSE endpoint is hit
by a request. This context can be used to reject an SSE connection before starting to send the event stream.- Since:
- 0.12.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidcustomizeResponse(Consumer<SseResponseCustomizer> responseCustomizer) Allows configuring certain parameters of the SSE initiator response.This method can be used to reject an SSE connection when a certain condition is not satisfied by the request.voidsetClientId(String overrideId) By default, aSseClientwill be created with a UUID as identifier.
-
Method Details
-
setClientId
By default, aSseClientwill be created with a UUID as identifier. This method allows overriding that client id. Avoid collisions is a responsibility of the method caller.- Parameters:
overrideId- the new id to be used instead of the UUID.
-
reject
This method can be used to reject an SSE connection when a certain condition is not satisfied by the request. Once you called this method, the event stream will not be sent.- Parameters:
statusCode- the status code of the response.reasonPhrase- the reason phrase to add in the response.- Returns:
- a future that will be completed when the response was successfully sent. It can also be completed exceptionally if the response failed to be sent.
-
customizeResponse
Allows configuring certain parameters of the SSE initiator response.- Parameters:
responseCustomizer- a callback that receives theSseResponseCustomizer.
-
getRequestContext
HttpRequestContext getRequestContext()- Returns:
- the context of the received request that matched an SSE endpoint.
-