Class HTTPServer.UriRouter
java.lang.Object
ch.autumo.beetroot.server.HTTPServer.UriRouter
- Enclosing class:
HTTPServer
Resolves a request URI to a registered route and processes the request
with that route's handler.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd route.org.nanohttpd.protocols.http.response.Responseprocess(org.nanohttpd.protocols.http.IHTTPSession session) Search in the mappings if the given url matches some of the rules If there are more than one marches returns the rule with less parameters e.g.voidsetNotFoundHandler(Class<?> handler) Sets the handler for URIs that match no route.voidsetNotImplemented(Class<?> handler) Sets the handler for routes without an implementation.voidsetRoutePrioritizer(HTTPServer.IRoutePrioritizer routePrioritizer) Replaces the route prioritizer.
-
Constructor Details
-
UriRouter
public UriRouter()Creates the router with the default route prioritizer.
-
-
Method Details
-
process
public org.nanohttpd.protocols.http.response.Response process(org.nanohttpd.protocols.http.IHTTPSession session) Search in the mappings if the given url matches some of the rules If there are more than one marches returns the rule with less parameters e.g. mapping 1 = /user/:id mapping 2 = /user/help if the incoming uri is www.example.com/user/help - mapping 2 is returned if the incoming uri is www.example.com/user/3232 - mapping 1 is returned- Parameters:
session- HTTP session- Returns:
- response
-
addRoute
-
setNotFoundHandler
Sets the handler for URIs that match no route.- Parameters:
handler- the handler class
-
setNotImplemented
Sets the handler for routes without an implementation.- Parameters:
handler- the handler class
-
setRoutePrioritizer
Replaces the route prioritizer.- Parameters:
routePrioritizer- the new prioritizer
-