Interface SseRequestContext


@Experimental @NoImplement @MinMuleVersion("4.10.0") public interface SseRequestContext
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 Details

    • setClientId

      void setClientId(String overrideId)
      By default, a SseClient will 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

      CompletableFuture<Void> reject(int statusCode, String reasonPhrase)
      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

      void customizeResponse(Consumer<SseResponseCustomizer> responseCustomizer)
      Allows configuring certain parameters of the SSE initiator response.
      Parameters:
      responseCustomizer - a callback that receives the SseResponseCustomizer.
    • getRequestContext

      HttpRequestContext getRequestContext()
      Returns:
      the context of the received request that matched an SSE endpoint.