public class Router extends Object
Modifier | Constructor and Description |
---|---|
protected |
Router(String rootControllerName) |
Modifier and Type | Method and Description |
---|---|
protected static String |
findControllerNamePart(String pack,
String uri)
Now that we know that this controller is under a package, need to find the controller short name.
|
protected String |
findPackageSuffix(String uri)
Finds a part of a package name which can be found in between "app.controllers" and short name of class.
|
static String |
generate(String controllerPath,
String action,
String id,
boolean restful,
Map params)
Generates a URI for a controller.
|
protected org.javalite.activeweb.ControllerPath |
getControllerPath(String uri)
Finds a controller path from URI.
|
protected Route |
recognize(String uri,
HttpMethod httpMethod)
This is a main method for recognizing a route to a controller; used when a request is received.
|
void |
setIgnoreSpecs(List<IgnoreSpec> ignoreSpecs) |
void |
setRoutes(List<RouteBuilder> routes)
Sets custom routes
|
protected Router(String rootControllerName)
public void setRoutes(List<RouteBuilder> routes)
routes
- se of custom routes defined for app.protected Route recognize(String uri, HttpMethod httpMethod) throws ClassLoadException
uri
- URI of incoming request.httpMethod
- http method of the request.Route
if one is found, null if not.ClassLoadException
public static String generate(String controllerPath, String action, String id, boolean restful, Map params)
controllerPath
- path to controller.action
- action for a controllerid
- id on a URIrestful
- true if a route for a restful controller is needed, false for non-restful.params
- name/value pairs to be used to form a query string.protected org.javalite.activeweb.ControllerPath getControllerPath(String uri)
http://host/context/admin/printers/show/1
, where "admin" is a "package_suffix", "printers" is a
"controller_name".
for example above, the method will Map with two keys: "package_suffix" and "controller_name"uri
- this is a URI - the information after context : "controller/action/whatever".protected static String findControllerNamePart(String pack, String uri)
pack
- part of the package of the controller, taken from URI: value between "app.controllers" and controller name.uri
- uri from requestprotected String findPackageSuffix(String uri)
uri
- uri from requestpublic void setIgnoreSpecs(List<IgnoreSpec> ignoreSpecs)
Copyright © 2019 JavaLite. All rights reserved.