Package play.mvc
Class Router
- java.lang.Object
-
- play.mvc.Router
-
public class Router extends java.lang.Object
The router matches HTTP requests to action invocations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Router.ActionDefinition
static class
Router.Route
-
Field Summary
Fields Modifier and Type Field Description static long
lastLoading
Timestamp the routes file was last loaded at.static java.util.List<Router.Route>
routes
All the loaded routes.
-
Constructor Summary
Constructors Constructor Description Router()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String headers)
Add a route at the given positionstatic 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 positionstatic 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 positionstatic 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 positionstatic void
addRoute(java.lang.String method, java.lang.String path, java.lang.String action, java.lang.String params, java.lang.String headers)
Add a routestatic 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 liststatic 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 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 Router.Route
route(Http.Request request)
static void
routeOnlyStatic(Http.Request request)
-
-
-
Field Detail
-
lastLoading
public static long lastLoading
Timestamp the routes file was last loaded at.
-
routes
public static java.util.List<Router.Route> routes
All the loaded routes.
-
-
Method Detail
-
load
public static void load(java.lang.String prefix)
Parse the routes file. This is called at startup.- Parameters:
prefix
- The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.
-
prependRoute
public 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. Last added is first in the route list.- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headers
-
prependRoute
public static void prependRoute(java.lang.String method, java.lang.String path, java.lang.String action)
This one can be called to add new route. Last added is first in the route list.- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated action
-
addRoute
public 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- Parameters:
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headers
-
addRoute
public static void addRoute(int position, java.lang.String method, java.lang.String path, java.lang.String headers)
Add a route at the given position- Parameters:
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeheaders
- The headers
-
addRoute
public 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- Parameters:
position
- The position where to insert the routemethod
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headers
-
addRoute
public static void addRoute(java.lang.String method, java.lang.String path, java.lang.String action)
Add a new route. Will be first in the route list- Parameters:
method
- The method of the route * @param action : The associated actionpath
- The path of the routeaction
- The associated action
-
addRoute
public 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- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated actionheaders
- The headers
-
addRoute
public 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- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headers
-
appendRoute
public 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. The order the routes are added matters and we want the method to append the routes to the list.- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headerssourceFile
- The source fileline
- The source line
-
getRoute
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)
-
getRoute
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)
-
prependRoute
public 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- Parameters:
method
- The method of the routepath
- The path of the routeaction
- The associated actionparams
- The parametersheaders
- The headers
-
detectChanges
public 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.
- Parameters:
prefix
- The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.
-
routeOnlyStatic
public static void routeOnlyStatic(Http.Request request)
-
route
public static Router.Route route(Http.Request request)
-
route
public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path)
-
route
public static java.util.Map<java.lang.String,java.lang.String> route(java.lang.String method, java.lang.String path, java.lang.String headers)
-
route
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)
-
reverse
public static Router.ActionDefinition reverse(java.lang.String action)
-
getFullUrl
public static java.lang.String getFullUrl(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
-
getBaseUrl
public static java.lang.String getBaseUrl()
-
getFullUrl
public static java.lang.String getFullUrl(java.lang.String action)
-
reverse
public static java.lang.String reverse(VirtualFile file)
-
reverse
public static java.lang.String reverse(VirtualFile file, boolean absolute)
-
reverseWithCheck
public static java.lang.String reverseWithCheck(java.lang.String name, VirtualFile file, boolean absolute)
-
reverse
public static Router.ActionDefinition reverse(java.lang.String action, java.util.Map<java.lang.String,java.lang.Object> args)
-
-