Interface DirectHandler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface DirectHandler
A handler that is invoked when a response is sent outside of routing. See DirectHandler.EventType to see which types of events are covered by this handler. Direct handlers can be used both with blocking and reactive servers in Helidon.
  • Method Details

    • defaultHandler

      static DirectHandler defaultHandler()
      Default handler will HTML encode the message (if any), use the default status code for the event type, and copy all headers configured.
      Returns:
      default direct handler
    • handle

      default DirectHandler.TransportResponse handle(DirectHandler.TransportRequest request, DirectHandler.EventType eventType, Status defaultStatus, ServerResponseHeaders responseHeaders, Throwable thrown)
      Handler of responses that bypass router.

      This method should be used to return custom status, header and possible entity. If there is a need to handle more details, please redirect the client to a proper endpoint to handle them. This method shall not send an unsafe message back as an entity to avoid potential data leaks.

      Parameters:
      request - request as received with as much known information as possible
      eventType - type of the event
      defaultStatus - default status expected to be returned
      responseHeaders - headers to be added to response
      thrown - throwable caught as part of processing with possible additional details about the reason of failure
      Returns:
      response to use to return to original request
    • handle

      default DirectHandler.TransportResponse handle(DirectHandler.TransportRequest request, DirectHandler.EventType eventType, Status defaultStatus, ServerResponseHeaders responseHeaders, Throwable thrown, System.Logger logger)
      Handler of responses that bypass router.

      This method should be used to return custom status, header and possible entity. If there is a need to handle more details, please redirect the client to a proper endpoint to handle them. This method shall not send an unsafe message back as an entity to avoid potential data leaks.

      Parameters:
      request - request as received with as much known information as possible
      eventType - type of the event
      defaultStatus - default status expected to be returned
      responseHeaders - headers to be added to response
      thrown - throwable caught as part of processing with possible additional details about the reason of failure
      logger - Possibly null logger to use for unsafe messages
      Returns:
      response to use to return to original request
    • handle

      DirectHandler.TransportResponse handle(DirectHandler.TransportRequest request, DirectHandler.EventType eventType, Status defaultStatus, ServerResponseHeaders responseHeaders, String message)
      Handler of responses that bypass routing.

      This method should be used to return custom status, header and possible entity. If there is a need to handle more details, please redirect the client to a proper endpoint to handle them.

      Parameters:
      request - request as received with as much known information as possible
      eventType - type of the event
      defaultStatus - default status expected to be returned
      responseHeaders - headers to be added to response
      message - informative message for cases that are not triggered by an exception, by default this will be called also for exceptional cases with the exception message
      Returns:
      response to use to return to original request