public class Router extends 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 List<Router.Route> |
routes
All the loaded routes.
|
Constructor and Description |
---|
Router() |
Modifier and Type | Method and Description |
---|---|
static void |
addRoute(int position,
String method,
String path,
String headers)
Add a route at the given position
|
static void |
addRoute(int position,
String method,
String path,
String action,
String headers)
Add a route at the given position
|
static void |
addRoute(int position,
String method,
String path,
String action,
String params,
String headers)
Add a route at the given position
|
static void |
addRoute(String method,
String path,
String action)
Add a new route.
|
static void |
addRoute(String method,
String path,
String action,
String headers)
Add a route at the given position
|
static void |
addRoute(String method,
String path,
String action,
String params,
String headers)
Add a route
|
static void |
appendRoute(String method,
String path,
String action,
String params,
String headers,
String sourceFile,
int line)
This is used internally when reading the route file.
|
static void |
detectChanges(String prefix)
In PROD mode and if the routes are already loaded, this does nothing.
|
static String |
getBaseUrl() |
static String |
getFullUrl(String action) |
static String |
getFullUrl(String action,
Map<String,Object> args) |
static Router.Route |
getRoute(String method,
String path,
String action,
String params,
String headers) |
static Router.Route |
getRoute(String method,
String path,
String action,
String params,
String headers,
String sourceFile,
int line) |
static void |
load(String prefix)
Parse the routes file.
|
static void |
prependRoute(String method,
String path,
String action)
This one can be called to add new route.
|
static void |
prependRoute(String method,
String path,
String action,
String headers)
This one can be called to add new route.
|
static void |
prependRoute(String method,
String path,
String action,
String params,
String headers)
Add a new route at the beginning of the route list
|
static Router.ActionDefinition |
reverse(String action) |
static Router.ActionDefinition |
reverse(String action,
Map<String,Object> args) |
static String |
reverse(VirtualFile file) |
static String |
reverse(VirtualFile file,
boolean absolute) |
static String |
reverseWithCheck(String name,
VirtualFile file,
boolean absolute) |
static Router.Route |
route(Http.Request request) |
static Map<String,String> |
route(String method,
String path) |
static Map<String,String> |
route(String method,
String path,
String headers) |
static Map<String,String> |
route(String method,
String path,
String headers,
String host) |
static void |
routeOnlyStatic(Http.Request request) |
public static long lastLoading
public static List<Router.Route> routes
public static void load(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(String method, String path, String action, String headers)
public static void prependRoute(String method, String path, String action)
public static void addRoute(int position, String method, String path, String action, String params, String headers)
public static void addRoute(int position, String method, String path, String headers)
public static void addRoute(int position, String method, String path, String action, String headers)
public static void addRoute(String method, String path, String action)
public static void addRoute(String method, String path, String action, String headers)
public static void addRoute(String method, String path, String action, String params, String headers)
public static void appendRoute(String method, String path, String action, String params, String headers, String sourceFile, int line)
public static Router.Route getRoute(String method, String path, String action, String params, String headers)
public static Router.Route getRoute(String method, String path, String action, String params, String headers, String sourceFile, int line)
public static void prependRoute(String method, String path, String action, String params, String headers)
public static void detectChanges(String prefix)
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 Map<String,String> route(String method, String path, String headers, String host)
public static Router.ActionDefinition reverse(String action)
public static String getBaseUrl()
public static String reverse(VirtualFile file)
public static String reverse(VirtualFile file, boolean absolute)
public static String reverseWithCheck(String name, VirtualFile file, boolean absolute)
public static Router.ActionDefinition reverse(String action, Map<String,Object> args)
Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly