Top Description Inners Fields Constructors Methods
io.undertow.server

public Class RoutingHandler

extends Object
implements HttpHandler
Class Inheritance
All Implemented Interfaces
io.undertow.server.HttpHandler
Imports
io.undertow.predicate.Predicate, io.undertow.server.handlers.ResponseCodeHandler, io.undertow.util.CopyOnWriteMap, .HttpString, .Methods, .PathTemplate, .PathTemplateMatch, .PathTemplateMatcher, java.util.List, .Map, .Map.Entry, java.util.concurrent.CopyOnWriteArrayList

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final PathTemplateMatcher<RoutingHandler.RoutingMatch>
private volatile HttpHandler
private volatile HttpHandler
private final Map<HttpString, PathTemplateMatcher<RoutingHandler.RoutingMatch>>
private final boolean

Constructor Summary

AccessConstructor and Description
public
RoutingHandler(boolean rewriteQueryParameters)

public

Method Summary

Modifier and TypeMethod and Description
public synchronized RoutingHandler
add(final String method, final String template, HttpHandler handler)

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

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

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

public synchronized RoutingHandler
addAll(RoutingHandler routingHandler)

public synchronized RoutingHandler
delete(final String template, HttpHandler handler)

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

public synchronized RoutingHandler
get(final String template, HttpHandler handler)

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

public HttpHandler

Returns:

Handler called when no match was found and invalid method handler can't be invoked.
getFallbackHandler
()

public HttpHandler

Returns:

Handler called when this instance can not match the http method but can match another http method.
getInvalidMethodHandler
()

pack-priv Map<HttpString, PathTemplateMatcher<RoutingHandler.RoutingMatch>>
private void
handleNoMatch(final HttpServerExchange
The object for which its handled the "no match" case.
exchange
)

Handles the case in with a match was not found for the http method but might exist for another http method.

public void
handleRequest(HttpServerExchange
the HTTP request/response exchange
exchange
)

Implements io.undertow.server.HttpHandler.handleRequest.

Handle the request.

public synchronized RoutingHandler
post(final String template, HttpHandler handler)

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

public synchronized RoutingHandler
put(final String template, HttpHandler handler)

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

public RoutingHandler

Returns:

this handler
remove
(HttpString
The method to remove
method
,
String
the path tempate to remove
path
)

Removes the specified route from the handler

public RoutingHandler

Returns:

this handler
remove
(String
the path tempate to remove
path
)

Removes the specified route from the handler

public RoutingHandler

Returns:

This instance.
setFallbackHandler
(HttpHandler
Handler that will be called when no match was found and invalid method handler can't be invoked.
fallbackHandler
)

public RoutingHandler

Returns:

This instance.
setInvalidMethodHandler
(HttpHandler
Handler that will be called when this instance can not match the http method but can match another http method.
invalidMethodHandler
)

Sets the handler called when this instance can not match the http method but can match another http method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allMethodsMatcherback to summary
private final PathTemplateMatcher<RoutingHandler.RoutingMatch> allMethodsMatcher
fallbackHandlerback to summary
private volatile HttpHandler fallbackHandler
invalidMethodHandlerback to summary
private volatile HttpHandler invalidMethodHandler
matchesback to summary
private final Map<HttpString, PathTemplateMatcher<RoutingHandler.RoutingMatch>> matches
rewriteQueryParametersback to summary
private final boolean rewriteQueryParameters

Constructor Detail

RoutingHandlerback to summary
public RoutingHandler(boolean rewriteQueryParameters)
RoutingHandlerback to summary
public RoutingHandler()

Method Detail

addback to summary
public synchronized RoutingHandler add(final String method, final String template, HttpHandler handler)
addback to summary
public synchronized RoutingHandler add(HttpString method, String template, HttpHandler handler)
addback to summary
public synchronized RoutingHandler add(final String method, final String template, Predicate predicate, HttpHandler handler)
addback to summary
public synchronized RoutingHandler add(HttpString method, String template, Predicate predicate, HttpHandler handler)
addAllback to summary
public synchronized RoutingHandler addAll(RoutingHandler routingHandler)
deleteback to summary
public synchronized RoutingHandler delete(final String template, HttpHandler handler)
deleteback to summary
public synchronized RoutingHandler delete(final String template, Predicate predicate, HttpHandler handler)
getback to summary
public synchronized RoutingHandler get(final String template, HttpHandler handler)
getback to summary
public synchronized RoutingHandler get(final String template, Predicate predicate, HttpHandler handler)
getFallbackHandlerback to summary
public HttpHandler getFallbackHandler()
Returns:HttpHandler

Handler called when no match was found and invalid method handler can't be invoked.

getInvalidMethodHandlerback to summary
public HttpHandler getInvalidMethodHandler()
Returns:HttpHandler

Handler called when this instance can not match the http method but can match another http method.

getMatchesback to summary
pack-priv Map<HttpString, PathTemplateMatcher<RoutingHandler.RoutingMatch>> getMatches()
handleNoMatchback to summary
private void handleNoMatch(final HttpServerExchange exchange) throws Exception

Handles the case in with a match was not found for the http method but might exist for another http method. For example: POST not matched for a path but at least one match exists for same path.

Parameters
exchange:HttpServerExchange

The object for which its handled the "no match" case.

handleRequestback to summary
public void handleRequest(HttpServerExchange exchange) throws Exception

Implements io.undertow.server.HttpHandler.handleRequest.

Doc from io.undertow.server.HttpHandler.handleRequest.

Handle the request.

Parameters
exchange:HttpServerExchange

the HTTP request/response exchange

Annotations
@Override
postback to summary
public synchronized RoutingHandler post(final String template, HttpHandler handler)
postback to summary
public synchronized RoutingHandler post(final String template, Predicate predicate, HttpHandler handler)
putback to summary
public synchronized RoutingHandler put(final String template, HttpHandler handler)
putback to summary
public synchronized RoutingHandler put(final String template, Predicate predicate, HttpHandler handler)
removeback to summary
public RoutingHandler remove(HttpString method, String path)

Removes the specified route from the handler

Parameters
method:HttpString

The method to remove

path:String

the path tempate to remove

Returns:RoutingHandler

this handler

removeback to summary
public RoutingHandler remove(String path)

Removes the specified route from the handler

Parameters
path:String

the path tempate to remove

Returns:RoutingHandler

this handler

setFallbackHandlerback to summary
public RoutingHandler setFallbackHandler(HttpHandler fallbackHandler)
Parameters
fallbackHandler:HttpHandler

Handler that will be called when no match was found and invalid method handler can't be invoked.

Returns:RoutingHandler

This instance.

setInvalidMethodHandlerback to summary
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:HttpHandler

Handler that will be called when this instance can not match the http method but can match another http method.

Returns:RoutingHandler

This instance.

io.undertow.server back to summary

private Class RoutingHandler.HandlerHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final HttpHandler
pack-priv final Predicate

Constructor Summary

AccessConstructor and Description
private
HandlerHolder(Predicate predicate, HttpHandler handler)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlerback to summary
pack-priv final HttpHandler handler
predicateback to summary
pack-priv final Predicate predicate

Constructor Detail

HandlerHolderback to summary
private HandlerHolder(Predicate predicate, HttpHandler handler)
io.undertow.server back to summary

private Class RoutingHandler.RoutingMatch

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile HttpHandler
pack-priv final List<RoutingHandler.HandlerHolder>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultHandlerback to summary
pack-priv volatile HttpHandler defaultHandler
predicatedHandlersback to summary
pack-priv final List<RoutingHandler.HandlerHolder> predicatedHandlers

Constructor Detail

RoutingMatchback to summary
private RoutingMatch()