public class Router
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Router.ActionDefinition |
static class |
Router.Route |
Modifier and Type | Field and Description |
---|---|
static long |
lastLoading
Timestamp the routes file was last loaded at.
|
static java.util.List<Router.Route> |
routes
All the loaded routes.
|
Constructor and Description |
---|
Router() |
Modifier and Type | Method and Description |
---|---|
static void |
addRoute(int position,
java.lang.String method,
java.lang.String path,
java.lang.String headers)
Add a route at the given position
|
static void |
addRoute(int position,
java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String headers)
Add a route at the given position
|
static void |
addRoute(int position,
java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers)
Add a route at the given position
|
static void |
addRoute(java.lang.String method,
java.lang.String path,
java.lang.String action)
Add a new route.
|
static void |
addRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String headers)
Add a route at the given position
|
static void |
addRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers)
Add a route
|
static void |
appendRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers,
java.lang.String sourceFile,
int line)
This is used internally when reading the route file.
|
static void |
detectChanges(java.lang.String prefix)
In PROD mode and if the routes are already loaded, this does nothing.
|
static java.lang.String |
getBaseUrl() |
static java.lang.String |
getFullUrl(java.lang.String action) |
static java.lang.String |
getFullUrl(java.lang.String action,
java.util.Map<java.lang.String,java.lang.Object> args) |
static Router.Route |
getRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers) |
static Router.Route |
getRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers,
java.lang.String sourceFile,
int line) |
static void |
load(java.lang.String prefix)
Parse the routes file.
|
static void |
prependRoute(java.lang.String method,
java.lang.String path,
java.lang.String action)
This one can be called to add new route.
|
static void |
prependRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String headers)
This one can be called to add new route.
|
static void |
prependRoute(java.lang.String method,
java.lang.String path,
java.lang.String action,
java.lang.String params,
java.lang.String headers)
Add a new route at the beginning of the route list
|
static Router.ActionDefinition |
reverse(java.lang.String action) |
static Router.ActionDefinition |
reverse(java.lang.String action,
java.util.Map<java.lang.String,java.lang.Object> args) |
static java.lang.String |
reverse(VirtualFile file) |
static java.lang.String |
reverse(VirtualFile file,
boolean absolute) |
static java.lang.String |
reverseWithCheck(java.lang.String name,
VirtualFile file,
boolean absolute) |
static Router.Route |
route(Http.Request request) |
static java.util.Map<java.lang.String,java.lang.String> |
route(java.lang.String method,
java.lang.String path) |
static java.util.Map<java.lang.String,java.lang.String> |
route(java.lang.String method,
java.lang.String path,
java.lang.String headers) |
static java.util.Map<java.lang.String,java.lang.String> |
route(java.lang.String method,
java.lang.String path,
java.lang.String headers,
java.lang.String host) |
static void |
routeOnlyStatic(Http.Request request) |
public static long lastLoading
public static java.util.List<Router.Route> routes
public static void load(java.lang.String prefix)
prefix
- The prefix that the path of all routes in this route file start with. This prefix should not end with
a '/' character.public static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
method
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headerspublic static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action)
method
- The method of the routepath
- The path of the routeaction
- The associated actionpublic static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headerspublic static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String headers)
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeheaders
- The headerspublic static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headerspublic static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action)
method
- The method of the route * @param action : The associated actionpath
- The path of the routeaction
- The associated actionpublic static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String headers)
method
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headerspublic static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headerspublic static void appendRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers, java.lang.String sourceFile, int line)
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headerssourceFile
- The source fileline
- The source linepublic static Router.Route getRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
public static Router.Route getRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers, java.lang.String sourceFile, int line)
public static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headerspublic static void detectChanges(java.lang.String prefix)
In PROD mode and if the routes are already loaded, this does nothing.
In DEV mode, this checks each routes file's "last modified" time to see if the routes need updated.
prefix
- The prefix that the path of all routes in this route file start with. This prefix should not end with
a '/' character.public static void routeOnlyStatic(Http.Request request)
public static Router.Route route(Http.Request request)
public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path)
public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path, java.lang.String headers)
public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path, java.lang.String headers, java.lang.String host)
public static Router.ActionDefinition reverse(java.lang.String action)
public static java.lang.String getFullUrl(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
public static java.lang.String getBaseUrl()
public static java.lang.String getFullUrl(java.lang.String action)
public static java.lang.String reverse(VirtualFile file)
public static java.lang.String reverse(VirtualFile file, boolean absolute)
public static java.lang.String reverseWithCheck(java.lang.String name, VirtualFile file, boolean absolute)
public static Router.ActionDefinition reverse(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly