Class RoutingHandler

  • All Implemented Interfaces:
    HttpHandler

    public class RoutingHandler
    extends java.lang.Object
    implements HttpHandler
    A Handler that handles the common case of routing via path template and method name.
    Author:
    Stuart Douglas
    • Constructor Detail

      • RoutingHandler

        public RoutingHandler​(boolean rewriteQueryParameters)
      • RoutingHandler

        public RoutingHandler()
    • Method Detail

      • handleRequest

        public void handleRequest​(HttpServerExchange exchange)
                           throws java.lang.Exception
        Description copied from interface: HttpHandler
        Handle the request.
        Specified by:
        handleRequest in interface HttpHandler
        Parameters:
        exchange - the HTTP request/response exchange
        Throws:
        java.lang.Exception
      • remove

        public RoutingHandler remove​(HttpString method,
                                     java.lang.String path)
        Removes the specified route from the handler
        Parameters:
        method - The method to remove
        path - the path tempate to remove
        Returns:
        this handler
      • remove

        public RoutingHandler remove​(java.lang.String path)
        Removes the specified route from the handler
        Parameters:
        path - the path tempate to remove
        Returns:
        this handler
      • getFallbackHandler

        public HttpHandler getFallbackHandler()
        Returns:
        Handler called when no match was found and invalid method handler can't be invoked.
      • setFallbackHandler

        public RoutingHandler setFallbackHandler​(HttpHandler fallbackHandler)
        Parameters:
        fallbackHandler - Handler that will be called when no match was found and invalid method handler can't be invoked.
        Returns:
        This instance.
      • getInvalidMethodHandler

        public HttpHandler getInvalidMethodHandler()
        Returns:
        Handler called when this instance can not match the http method but can match another http method.
      • setInvalidMethodHandler

        public RoutingHandler setInvalidMethodHandler​(HttpHandler invalidMethodHandler)
        Sets the handler called when this instance can not match the http method but can match another http method. For example: For an exchange the POST method is not matched by this instance but at least one http method matched for the exchange. If this handler is null the fallbackHandler will be used.
        Parameters:
        invalidMethodHandler - Handler that will be called when this instance can not match the http method but can match another http method.
        Returns:
        This instance.