Class DelegatingHandler

java.lang.Object
dev.mccue.microhttp.handler.DelegatingHandler
All Implemented Interfaces:
Handler

public abstract class DelegatingHandler extends Object implements Handler
Template for a class which has a list of handlers that it tries in order.
  • Constructor Details

    • DelegatingHandler

      public DelegatingHandler(List<Handler> handlers, IntoResponse notHandled)
      Parameters:
      handlers - The list of handlers, in the order they should be tried.
      notHandled - The IntoResponse to use if no handler matches the request.
  • Method Details

    • handle

      public IntoResponse handle(org.microhttp.Request request) throws Exception
      Description copied from interface: Handler
      Handles the request.

      If null is returned, that means that the handler is signaling that it does not want to handle the Request. This would signal that another Handler should be consulted or a default response should be used

      Specified by:
      handle in interface Handler
      Parameters:
      request - The request to handle.
      Returns:
      Something which can be converted into a response or null.
      Throws:
      Exception - If something goes wrong.