public class PathHandler extends Object implements HttpHandler
This only matches a single level of a request, e.g if you have a request that takes the form:
/foo/bar
Constructor and Description |
---|
PathHandler() |
PathHandler(HttpHandler defaultHandler) |
PathHandler(HttpHandler defaultHandler, int cacheSize) |
PathHandler(int cacheSize) |
Modifier and Type | Method and Description |
---|---|
PathHandler | addExactPath(String path, HttpHandler handler) If the request path is exactly equal to the given path, run the handler. |
PathHandler | addPath(String path, HttpHandler handler) Deprecated. Superseded by addPrefixPath(String, io.undertow.server.HttpHandler) . |
PathHandler | addPrefixPath(String path, HttpHandler handler) Adds a path prefix and a handler for that path. |
PathHandler | clearPaths() |
void | handleRequest(HttpServerExchange exchange) Handle the request. |
PathHandler | removeExactPath(String path) |
PathHandler | removePath(String path) Deprecated. |
PathHandler | removePrefixPath(String path) |
public PathHandler(HttpHandler defaultHandler)
public PathHandler(HttpHandler defaultHandler, int cacheSize)
public PathHandler()
public PathHandler(int cacheSize)
public void handleRequest(HttpServerExchange exchange) throws Exception
HttpHandler
handleRequest
in interface HttpHandler
exchange
- the HTTP request/response exchangeException
@Deprecated public PathHandler addPath(String path, HttpHandler handler)
addPrefixPath(String, io.undertow.server.HttpHandler)
.The match is done on a prefix bases, so registering /foo will also match /bar. Exact path matches are taken into account first.
If / is specified as the path then it will replace the default handler.
path
- The pathhandler
- The handleraddPrefixPath(String, io.undertow.server.HttpHandler)
public PathHandler addPrefixPath(String path, HttpHandler handler)
The match is done on a prefix bases, so registering /foo will also match /foo/bar. Though exact path matches are taken into account before prefix path matches. So if an exact path match exists it's handler will be triggered.
If / is specified as the path then it will replace the default handler.
path
- If the request contains this prefix, run handler.handler
- The handler which is activated upon match.public PathHandler addExactPath(String path, HttpHandler handler)
Exact paths are prioritized higher than prefix paths.
path
- If the request path is exactly this, run handler.handler
- Handler run upon exact path match.@Deprecated public PathHandler removePath(String path)
public PathHandler removePrefixPath(String path)
public PathHandler removeExactPath(String path)
public PathHandler clearPaths()
Copyright © 2015 JBoss by Red Hat. All rights reserved.