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
`static class` `Router.ActionDefinition`
`static class` `Router.Route`

### Field Summary

Fields
`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 and Description
`Router()`

### Method Summary

All Methods Static Methods Concrete Methods
`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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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.

### Constructor Detail

#### Router

    public Router()

### 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 route
  `path` - The path of the route
  `action` - The associated action
  `headers` - 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 route
  `path` - The path of the route
  `action` - 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 route
  `method` - The method of the route
  `path` - The path of the route
  `action` - The associated action
  `params` - The parameters
  `headers` - 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 route
  `method` - The method of the route
  `path` - The path of the route
  `headers` - 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 route
  `method` - The method of the route
  `path` - The path of the route
  `action` - The associated action
  `headers` - 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 action
  `path` - The path of the route
  `action` - 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 route
  `path` - The path of the route
  `action` - The associated action
  `headers` - 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 route
  `path` - The path of the route
  `action` - The associated action
  `params` - The parameters
  `headers` - 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 route
  `path` - The path of the route
  `action` - The associated action
  `params` - The parameters
  `headers` - The headers
  `sourceFile` - The source file
  `line` - 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 route
  `path` - The path of the route
  `action` - The associated action
  `params` - The parameters
  `headers` - 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)