Package io.undertow.server.handlers
Class PathHandler
java.lang.Object
io.undertow.server.handlers.PathHandler
- All Implemented Interfaces:
HttpHandler
Handler that dispatches to a given handler based of a prefix match of the path.
This only matches a single level of a request, e.g if you have a request that takes the form:
/foo/bar
- Author:
- Stuart Douglas
-
Constructor Summary
ConstructorsConstructorDescriptionPathHandler(int cacheSize) PathHandler(HttpHandler defaultHandler) PathHandler(HttpHandler defaultHandler, int cacheSize) -
Method Summary
Modifier and TypeMethodDescriptionaddExactPath(String path, HttpHandler handler) If the request path is exactly equal to the given path, run the handler.addPath(String path, HttpHandler handler) Deprecated.addPrefixPath(String path, HttpHandler handler) Adds a path prefix and a handler for that path.voidhandleRequest(HttpServerExchange exchange) Handle the request.removeExactPath(String path) removePath(String path) Deprecated.removePrefixPath(String path)
-
Constructor Details
-
PathHandler
-
PathHandler
-
PathHandler
public PathHandler() -
PathHandler
public PathHandler(int cacheSize)
-
-
Method Details
-
handleRequest
Description copied from interface:HttpHandlerHandle the request.- Specified by:
handleRequestin interfaceHttpHandler- Parameters:
exchange- the HTTP request/response exchange- Throws:
Exception
-
addPath
Deprecated.Superseded byaddPrefixPath(String, io.undertow.server.HttpHandler).Adds a path prefix and a handler for that path. If the path does not start with a / then one will be prepended.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.
- Parameters:
path- The pathhandler- The handler- See Also:
-
addPrefixPath
Adds a path prefix and a handler for that path. If the path does not start with a / then one will be prepended.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.
- Parameters:
path- If the request contains this prefix, run handler.handler- The handler which is activated upon match.- Returns:
- The resulting PathHandler after this path has been added to it.
-
addExactPath
If the request path is exactly equal to the given path, run the handler.Exact paths are prioritized higher than prefix paths.
- Parameters:
path- If the request path is exactly this, run handler.handler- Handler run upon exact path match.- Returns:
- The resulting PathHandler after this path has been added to it.
-
removePath
Deprecated. -
removePrefixPath
-
removeExactPath
-
clearPaths
-
addPrefixPath(String, io.undertow.server.HttpHandler).