public class Handlers extends Object
Modifier and Type | Method and Description |
---|---|
static AccessControlListHandler |
acl(HttpHandler next,
boolean defaultAllow,
ExchangeAttribute attribute)
Returns a new handler that can allow or deny access to a resource based an at attribute of the exchange
|
static DateHandler |
date(HttpHandler next)
Deprecated.
|
static HttpHandler |
disableCache(HttpHandler next)
Handler that sets the headers that disable caching of the response
|
static ExceptionHandler |
exceptionHandler(HttpHandler next)
Returns a handler that maps exceptions to additional handlers
|
static GracefulShutdownHandler |
gracefulShutdown(HttpHandler next)
Returns a new handler that can be used to wait for all requests to finish before shutting down the server gracefully.
|
static void |
handlerNotNull(HttpHandler handler) |
static SetHeaderHandler |
header(HttpHandler next,
String headerName,
ExchangeAttribute headerValue)
Returns a handler that sets a response header
|
static SetHeaderHandler |
header(HttpHandler next,
String headerName,
String headerValue)
Returns a handler that sets a response header
|
static HttpContinueAcceptingHandler |
httpContinueAccepting(HttpHandler next)
Returns a handler that sends back a HTTP 100 continue response to all requests.
|
static HttpContinueAcceptingHandler |
httpContinueAccepting(HttpHandler next,
Predicate accept)
Returns a handler that sends back a HTTP 100 continue response if the given predicate resolves to true.
|
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 JvmRouteHandler |
jvmRoute(String sessionCookieName,
String jvmRoute,
HttpHandler next)
Handler that appends the JVM route to the session cookie
|
static LearningPushHandler |
learningPushHandler(int maxEntries,
HttpHandler next)
Creates a handler that automatically learns which resources to push based on the referer header
|
static LearningPushHandler |
learningPushHandler(int maxEntries,
int maxAge,
HttpHandler next)
Creates a handler that automatically learns which resources to push based on the referer header
|
static PathHandler |
path()
Creates a new path handler
|
static PathHandler |
path(HttpHandler defaultHandler)
Creates a new path handler, with the default handler specified
|
static PathTemplateHandler |
pathTemplate() |
static PathTemplateHandler |
pathTemplate(boolean rewriteQueryParams) |
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 ProxyHandler |
proxyHandler(ProxyClient proxyClient)
Returns a handler that can act as a load balancing reverse proxy.
|
static ProxyHandler |
proxyHandler(ProxyClient proxyClient,
HttpHandler next)
Returns a handler that can act as a load balancing reverse proxy.
|
static ProxyHandler |
proxyHandler(ProxyClient proxyClient,
int maxRequestTime,
HttpHandler next)
Returns a handler that can act as a load balancing reverse proxy.
|
static ProxyPeerAddressHandler |
proxyPeerAddress(HttpHandler next)
Returns a new handler that sets the peer address based on the X-Forwarded-For and
X-Forwarded-Proto header
|
static RedirectHandler |
redirect(String location)
Returns a new redirect handler
|
static HttpHandler |
requestDump(HttpHandler next)
Returns a handler that dumps requests to the log for debugging purposes.
|
static RequestLimitingHandler |
requestLimitingHandler(int maxRequest,
int queueSize,
HttpHandler next)
Returns a handler that limits the maximum number of requests that can run at a time.
|
static RequestLimitingHandler |
requestLimitingHandler(RequestLimit requestLimit,
HttpHandler next)
Returns a handler that limits the maximum number of requests that can run at a time.
|
static ResourceHandler |
resource(ResourceManager resourceManager)
Return a new resource handler
|
static ResponseRateLimitingHandler |
responseRateLimitingHandler(HttpHandler next,
int bytes,
long time,
TimeUnit timeUnit)
A handler that limits the download speed to a set number of bytes/period
|
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 RoutingHandler |
routing() |
static RoutingHandler |
routing(boolean rewriteQueryParams) |
static ServerSentEventHandler |
serverSentEvents()
A handler for server sent events
|
static ServerSentEventHandler |
serverSentEvents(ServerSentEventConnectionCallback callback)
A handler for server sent events
|
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 HttpHandler |
urlDecodingHandler(String charset,
HttpHandler next)
Returns a new handler that decodes the URL and query parameters into the specified charset, assuming it
has not already been done by the connector.
|
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 PathTemplateHandler pathTemplate()
public static RoutingHandler routing(boolean rewriteQueryParams)
rewriteQueryParams
- If the query params should be rewrittenpublic static RoutingHandler routing()
public static PathTemplateHandler pathTemplate(boolean rewriteQueryParams)
rewriteQueryParams
- If the query params should be rewrittenpublic 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 ServerSentEventHandler serverSentEvents(ServerSentEventConnectionCallback callback)
callback
- The server sent events callbackpublic static ServerSentEventHandler serverSentEvents()
public 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)
WARNING: enabling trace requests may leak information, in general it is recommended that these be disabled for security reasons.
next
- The next handler in the chain@Deprecated public 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 SetHeaderHandler header(HttpHandler next, String headerName, ExchangeAttribute 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 AccessControlListHandler acl(HttpHandler next, boolean defaultAllow, ExchangeAttribute attribute)
next
- The next handler in the chaindefaultAllow
- Determine if a non-matching user agent will be allowed by defaultpublic static final HttpContinueReadHandler httpContinueRead(HttpHandler next)
next
- The next handler in the chainpublic static final HttpContinueAcceptingHandler httpContinueAccepting(HttpHandler next, Predicate accept)
httpContinueRead(io.undertow.server.HttpHandler)
in
that it will eagerly send the response, and not wait for the first read attempt.next
- The next handleraccept
- The predicate used to determine if the request should be acceptedpublic static final HttpContinueAcceptingHandler httpContinueAccepting(HttpHandler next)
httpContinueRead(io.undertow.server.HttpHandler)
in
that it will eagerly send the response, and not wait for the first read attempt.next
- The next handlerpublic static final URLDecodingHandler urlDecoding(HttpHandler next, String charset)
If you are using this handler you must set the 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 handlerpublic static HttpHandler urlDecodingHandler(String charset, HttpHandler next)
UndertowOptions.DECODE_URL
must have been set to false.charset
- The charset to decodenext
- The next handlerpublic static GracefulShutdownHandler gracefulShutdown(HttpHandler next)
next
- The next http handlerpublic static ProxyPeerAddressHandler proxyPeerAddress(HttpHandler next)
next
- The next http handlerpublic static JvmRouteHandler jvmRoute(String sessionCookieName, String jvmRoute, HttpHandler next)
sessionCookieName
- The session cookie namejvmRoute
- The JVM route to appendnext
- The next handlerpublic static RequestLimitingHandler requestLimitingHandler(int maxRequest, int queueSize, HttpHandler next)
maxRequest
- The maximum number of requestsqueueSize
- The maximum number of queued requestsnext
- The next handlerpublic static RequestLimitingHandler requestLimitingHandler(RequestLimit requestLimit, HttpHandler next)
requestLimit
- The request limit object that can be shared between handlers, to apply the same limits across multiple handlersnext
- The next handlerpublic static ProxyHandler proxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next)
proxyClient
- The proxy client to use to connect to the remote servermaxRequestTime
- The maximum amount of time a request can be in progress before it is forcibly closednext
- The next handler to invoke if the proxy client does not know how to proxy the requestpublic static ProxyHandler proxyHandler(ProxyClient proxyClient, HttpHandler next)
proxyClient
- The proxy client to use to connect to the remote servernext
- The next handler to invoke if the proxy client does not know how to proxy the requestpublic static ProxyHandler proxyHandler(ProxyClient proxyClient)
proxyClient
- The proxy client to use to connect to the remote serverpublic static HttpHandler disableCache(HttpHandler next)
next
- The next handlerpublic static HttpHandler requestDump(HttpHandler next)
next
- The next handlerpublic static ExceptionHandler exceptionHandler(HttpHandler next)
next
- The next handlerpublic static ResponseRateLimitingHandler responseRateLimitingHandler(HttpHandler next, int bytes, long time, TimeUnit timeUnit)
next
- The next handlerbytes
- The number of bytes per time periodtime
- The time periodtimeUnit
- The units of the time periodpublic static LearningPushHandler learningPushHandler(int maxEntries, int maxAge, HttpHandler next)
maxEntries
- The maximum number of entries to storemaxAge
- The maximum age of the entriesnext
- The next handlerpublic static LearningPushHandler learningPushHandler(int maxEntries, HttpHandler next)
maxEntries
- The maximum number of entries to storenext
- The next handlerpublic static void handlerNotNull(HttpHandler handler)
Copyright © 2016 JBoss by Red Hat. All rights reserved.