public class Handlers extends Object
Modifier and Type | Method and Description |
---|---|
static DateHandler |
date(HttpHandler next)
Returns a new HTTP handler that sets the Date: header.
|
static SetHeaderHandler |
header(HttpHandler next,
String headerName,
String headerValue)
Returns a handler that sets a response header
|
static HttpContinueReadHandler |
httpContinueRead(HttpHandler next)
A handler that automatically handles HTTP 100-continue responses, by sending a continue
response when the first attempt is made to read from the request channel.
|
static IPAddressAccessControlHandler |
ipAccessControl(HttpHandler next,
boolean defaultAllow)
Returns a new handler that can allow or deny access to a resource based on IP address
|
static PathHandler |
path()
Creates a new path handler
|
static PathHandler |
path(HttpHandler defaultHandler)
Creates a new path handler, with the default handler specified
|
static PredicateHandler |
predicate(Predicate predicate,
HttpHandler trueHandler,
HttpHandler falseHandler)
Returns a new predicate handler, that will delegate to one of the two provided handlers based on the value of the
provided predicate.
|
static HttpHandler |
predicateContext(HttpHandler next) |
static PredicatesHandler |
predicates(List<PredicatedHandler> handlers,
HttpHandler next) |
static RedirectHandler |
redirect(String location)
Returns a new redirect handler
|
static ResourceHandler |
resource(ResourceManager resourceManager)
Return a new resource handler
|
static HttpHandler |
rewrite(String condition,
String target,
ClassLoader classLoader,
HttpHandler next)
Creates the set of handlers that are required to perform a simple rewrite.
|
static SetAttributeHandler |
setAttribute(HttpHandler next,
String attribute,
String value,
ClassLoader classLoader)
Returns an attribute setting handler that can be used to set an arbitrary attribute on the exchange.
|
static HttpTraceHandler |
trace(HttpHandler next)
Returns a new HTTP trace handler.
|
static URLDecodingHandler |
urlDecoding(HttpHandler next,
String charset)
A handler that will decode the URL, query parameters and to the specified charset.
|
static NameVirtualHostHandler |
virtualHost()
Creates a new virtual host handler
|
static NameVirtualHostHandler |
virtualHost(HttpHandler defaultHandler)
Creates a new virtual host handler using the provided default handler
|
static NameVirtualHostHandler |
virtualHost(HttpHandler defaultHandler,
HttpHandler hostHandler,
String... hostnames)
Creates a new virtual host handler that uses the provided handler as the root handler for the given hostnames.
|
static NameVirtualHostHandler |
virtualHost(HttpHandler hostHandler,
String... hostnames)
Creates a new virtual host handler that uses the provided handler as the root handler for the given hostnames.
|
static WebSocketProtocolHandshakeHandler |
websocket(WebSocketConnectionCallback sessionHandler) |
static WebSocketProtocolHandshakeHandler |
websocket(WebSocketConnectionCallback sessionHandler,
HttpHandler next) |
public static PathHandler path(HttpHandler defaultHandler)
defaultHandler
- The default handlerpublic static PathHandler path()
public static NameVirtualHostHandler virtualHost()
public static NameVirtualHostHandler virtualHost(HttpHandler defaultHandler)
public static NameVirtualHostHandler virtualHost(HttpHandler hostHandler, String... hostnames)
hostHandler
- The host handlerhostnames
- The host namespublic static NameVirtualHostHandler virtualHost(HttpHandler defaultHandler, HttpHandler hostHandler, String... hostnames)
defaultHandler
- The default handlerhostHandler
- The host handlerhostnames
- The host namespublic static WebSocketProtocolHandshakeHandler websocket(WebSocketConnectionCallback sessionHandler)
sessionHandler
- The web socket session handlerpublic static WebSocketProtocolHandshakeHandler websocket(WebSocketConnectionCallback sessionHandler, HttpHandler next)
sessionHandler
- The web socket session handlernext
- The handler to invoke if the web socket connection failspublic static ResourceHandler resource(ResourceManager resourceManager)
resourceManager
- The resource manager to usepublic static RedirectHandler redirect(String location)
location
- The redirect locationpublic static HttpTraceHandler trace(HttpHandler next)
next
- The next handler in the chainpublic static DateHandler date(HttpHandler next)
next
- The next handler in the chainpublic static PredicateHandler predicate(Predicate predicate, HttpHandler trueHandler, HttpHandler falseHandler)
predicate
- The predicatetrueHandler
- The handler that will be executed if the predicate is truefalseHandler
- The handler that will be exected if the predicate is falsePredicate
,
Predicates
public static HttpHandler predicateContext(HttpHandler next)
next
- The next handlerpublic static PredicatesHandler predicates(List<PredicatedHandler> handlers, HttpHandler next)
public static SetHeaderHandler header(HttpHandler next, String headerName, String headerValue)
next
- The next handler in the chainheaderName
- The name of the headerheaderValue
- The header valuepublic static final IPAddressAccessControlHandler ipAccessControl(HttpHandler next, boolean defaultAllow)
next
- The next handler in the chaindefaultAllow
- Determine if a non-matching address will be allowed by defaultpublic static final HttpContinueReadHandler httpContinueRead(HttpHandler next)
next
- The next handler in the chainpublic static final URLDecodingHandler urlDecoding(HttpHandler next, String charset)
UndertowOptions.DECODE_URL
parameter to false.
This is not as efficient as using the parsers built in UTF-8 decoder. Unless you need to decode to something other
than UTF-8 you should rely on the parsers decoding instead.next
- The next handler in the chaincharset
- The charset to decode topublic static SetAttributeHandler setAttribute(HttpHandler next, String attribute, String value, ClassLoader classLoader)
next
- The next handlerattribute
- The attribute to set, specified as a string presentation of an ExchangeAttribute
value
- The value to set, specified an a string representation of an ExchangeAttribute
classLoader
- The class loader to use to parser the exchange attributespublic static HttpHandler rewrite(String condition, String target, ClassLoader classLoader, HttpHandler next)
condition
- The rewrite conditiontarget
- The rewrite target if the condition matchesnext
- The next handlerCopyright © 2013 JBoss by Red Hat. All rights reserved.