io.undertow.server

## Class RoutingHandler

- java.lang.Object
- - io.undertow.server.RoutingHandler

All Implemented Interfaces:
  HttpHandler

    public class RoutingHandler
    extends Object
    implements HttpHandler

A Handler that handles the common case of routing via path template and method name.

Author:
  Stuart Douglas

### Constructor Summary

Constructors
Constructor and Description
`RoutingHandler()`
`RoutingHandler(boolean rewriteQueryParameters)`

### Method Summary

All Methods Instance Methods Concrete Methods
`RoutingHandler` `add(HttpString method, String template, HttpHandler handler)`
`RoutingHandler` `add(HttpString method, String template, Predicate predicate, HttpHandler handler)`
`RoutingHandler` `add(String method, String template, HttpHandler handler)`
`RoutingHandler` `add(String method, String template, Predicate predicate, HttpHandler handler)`
`RoutingHandler` `addAll(RoutingHandler routingHandler)`
`RoutingHandler` `delete(String template, HttpHandler handler)`
`RoutingHandler` `delete(String template, Predicate predicate, HttpHandler handler)`
`RoutingHandler` `get(String template, HttpHandler handler)`
`RoutingHandler` `get(String template, Predicate predicate, HttpHandler handler)`
`HttpHandler` `getFallbackHandler()`
`HttpHandler` `getInvalidMethodHandler()`
`void` `handleRequest(HttpServerExchange exchange)` Handle the request.
`RoutingHandler` `post(String template, HttpHandler handler)`
`RoutingHandler` `post(String template, Predicate predicate, HttpHandler handler)`
`RoutingHandler` `put(String template, HttpHandler handler)`
`RoutingHandler` `put(String template, Predicate predicate, HttpHandler handler)`
`RoutingHandler` `remove(HttpString method, String path)` Removes the specified route from the handler
`RoutingHandler` `remove(String path)` Removes the specified route from the handler
`RoutingHandler` `setFallbackHandler(HttpHandler fallbackHandler)`
`RoutingHandler` `setInvalidMethodHandler(HttpHandler invalidMethodHandler)` Sets the handler called when this instance can not match the http method but can match another http method.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RoutingHandler

    public RoutingHandler(boolean rewriteQueryParameters)

#### RoutingHandler

    public RoutingHandler()

### Method Detail

#### handleRequest

    public void handleRequest(HttpServerExchange exchange)
                       throws Exception

Description copied from interface: `HttpHandler`
Handle the request.

Specified by:
  `handleRequest` in interface `HttpHandler`
Parameters:
  `exchange` - the HTTP request/response exchange
Throws:
  `Exception`

#### add

    public RoutingHandler add(String method,
                              String template,
                              HttpHandler handler)

#### add

    public RoutingHandler add(HttpString method,
                              String template,
                              HttpHandler handler)

#### get

    public RoutingHandler get(String template,
                              HttpHandler handler)

#### post

    public RoutingHandler post(String template,
                               HttpHandler handler)

#### put

    public RoutingHandler put(String template,
                              HttpHandler handler)

#### delete

    public RoutingHandler delete(String template,
                                 HttpHandler handler)

#### add

    public RoutingHandler add(String method,
                              String template,
                              Predicate predicate,
                              HttpHandler handler)

#### add

    public RoutingHandler add(HttpString method,
                              String template,
                              Predicate predicate,
                              HttpHandler handler)

#### get

    public RoutingHandler get(String template,
                              Predicate predicate,
                              HttpHandler handler)

#### post

    public RoutingHandler post(String template,
                               Predicate predicate,
                               HttpHandler handler)

#### put

    public RoutingHandler put(String template,
                              Predicate predicate,
                              HttpHandler handler)

#### delete

    public RoutingHandler delete(String template,
                                 Predicate predicate,
                                 HttpHandler handler)

#### addAll

    public RoutingHandler addAll(RoutingHandler routingHandler)

#### remove

    public RoutingHandler remove(HttpString method,
                                 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(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.