Package io.undertow.server
Class RoutingHandler
- java.lang.Object
-
- io.undertow.server.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 Summary
Constructors Constructor Description RoutingHandler()
RoutingHandler(boolean rewriteQueryParameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RoutingHandler
add(HttpString method, java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
add(HttpString method, java.lang.String template, HttpHandler handler)
RoutingHandler
add(java.lang.String method, java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
add(java.lang.String method, java.lang.String template, HttpHandler handler)
RoutingHandler
addAll(RoutingHandler routingHandler)
RoutingHandler
delete(java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
delete(java.lang.String template, HttpHandler handler)
RoutingHandler
get(java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
get(java.lang.String template, HttpHandler handler)
HttpHandler
getFallbackHandler()
HttpHandler
getInvalidMethodHandler()
void
handleRequest(HttpServerExchange exchange)
Handle the request.RoutingHandler
post(java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
post(java.lang.String template, HttpHandler handler)
RoutingHandler
put(java.lang.String template, Predicate predicate, HttpHandler handler)
RoutingHandler
put(java.lang.String template, HttpHandler handler)
RoutingHandler
remove(HttpString method, java.lang.String path)
Removes the specified route from the handlerRoutingHandler
remove(java.lang.String path)
Removes the specified route from the handlerRoutingHandler
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.
-
-
-
Method Detail
-
handleRequest
public void handleRequest(HttpServerExchange exchange) throws java.lang.Exception
Description copied from interface:HttpHandler
Handle the request.- Specified by:
handleRequest
in interfaceHttpHandler
- Parameters:
exchange
- the HTTP request/response exchange- Throws:
java.lang.Exception
-
add
public RoutingHandler add(java.lang.String method, java.lang.String template, HttpHandler handler)
-
add
public RoutingHandler add(HttpString method, java.lang.String template, HttpHandler handler)
-
get
public RoutingHandler get(java.lang.String template, HttpHandler handler)
-
post
public RoutingHandler post(java.lang.String template, HttpHandler handler)
-
put
public RoutingHandler put(java.lang.String template, HttpHandler handler)
-
delete
public RoutingHandler delete(java.lang.String template, HttpHandler handler)
-
add
public RoutingHandler add(java.lang.String method, java.lang.String template, Predicate predicate, HttpHandler handler)
-
add
public RoutingHandler add(HttpString method, java.lang.String template, Predicate predicate, HttpHandler handler)
-
get
public RoutingHandler get(java.lang.String template, Predicate predicate, HttpHandler handler)
-
post
public RoutingHandler post(java.lang.String template, Predicate predicate, HttpHandler handler)
-
put
public RoutingHandler put(java.lang.String template, Predicate predicate, HttpHandler handler)
-
delete
public RoutingHandler delete(java.lang.String template, Predicate predicate, HttpHandler handler)
-
addAll
public RoutingHandler addAll(RoutingHandler routingHandler)
-
remove
public RoutingHandler remove(HttpString method, java.lang.String path)
Removes the specified route from the handler- Parameters:
method
- The method to removepath
- 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.
-
-