Package io.undertow.server.handlers
Class PathHandler
- java.lang.Object
-
- io.undertow.server.handlers.PathHandler
-
- All Implemented Interfaces:
HttpHandler
public class PathHandler extends Object implements 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
Constructors Constructor Description PathHandler()
PathHandler(int cacheSize)
PathHandler(HttpHandler defaultHandler)
PathHandler(HttpHandler defaultHandler, int cacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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 byaddPrefixPath(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)
String
toString()
-
-
-
Constructor Detail
-
PathHandler
public PathHandler(HttpHandler defaultHandler)
-
PathHandler
public PathHandler(HttpHandler defaultHandler, int cacheSize)
-
PathHandler
public PathHandler()
-
PathHandler
public PathHandler(int cacheSize)
-
-
Method Detail
-
handleRequest
public void handleRequest(HttpServerExchange exchange) throws Exception
Description copied from interface:HttpHandler
Handle the request.- Specified by:
handleRequest
in interfaceHttpHandler
- Parameters:
exchange
- the HTTP request/response exchange- Throws:
Exception
-
addPath
@Deprecated public PathHandler addPath(String path, HttpHandler handler)
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 /foo/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(String, io.undertow.server.HttpHandler)
-
addPrefixPath
public PathHandler addPrefixPath(String path, HttpHandler handler)
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 its 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
public PathHandler addExactPath(String path, HttpHandler handler)
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 public PathHandler removePath(String path)
Deprecated.
-
removePrefixPath
public PathHandler removePrefixPath(String path)
-
removeExactPath
public PathHandler removeExactPath(String path)
-
clearPaths
public PathHandler clearPaths()
-
-