Package ninja
Class Route
- java.lang.Object
-
- ninja.Route
-
public class Route extends Object
A route
-
-
Field Summary
Fields Modifier and Type Field Description static String
HTTP_METHOD_DELETE
static String
HTTP_METHOD_GET
static String
HTTP_METHOD_HEAD
static String
HTTP_METHOD_OPTIONS
static String
HTTP_METHOD_POST
static String
HTTP_METHOD_PUT
static String
HTTP_METHOD_WEBSOCKET
-
Constructor Summary
Constructors Constructor Description Route(String httpMethod, String uri, Method controllerMethod, FilterChain filterChain)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static String
convertRawUriToRegex(String rawUri)
Gets a raw uri like "/{name}/id/*" and returns "/([^/]*)/id/*." Also handles regular expressions if defined inside routes: For instance "/users/{username: [a-zA-Z][a-zA-Z_0-9]}" becomes "/users/([a-zA-Z][a-zA-Z_0-9])"Class<?>
getControllerClass()
Method
getControllerMethod()
FilterChain
getFilterChain()
String
getHttpMethod()
Map<String,RouteParameter>
getParameters()
Map<String,String>
getPathParametersEncoded(String uri)
This method does not do any decoding / encoding.String
getUri()
String
getUrl()
Deprecated.Use getUri()boolean
isHttpMethod(String method)
boolean
isHttpMethodDelete()
boolean
isHttpMethodGet()
boolean
isHttpMethodHead()
boolean
isHttpMethodOptions()
boolean
isHttpMethodPost()
boolean
isHttpMethodPut()
boolean
isHttpMethodWebSocket()
boolean
matches(String httpMethod, String uri)
Matches /index to /index or /me/1 to /person/{id}
-
-
-
Field Detail
-
HTTP_METHOD_GET
public static final String HTTP_METHOD_GET
- See Also:
- Constant Field Values
-
HTTP_METHOD_POST
public static final String HTTP_METHOD_POST
- See Also:
- Constant Field Values
-
HTTP_METHOD_PUT
public static final String HTTP_METHOD_PUT
- See Also:
- Constant Field Values
-
HTTP_METHOD_HEAD
public static final String HTTP_METHOD_HEAD
- See Also:
- Constant Field Values
-
HTTP_METHOD_DELETE
public static final String HTTP_METHOD_DELETE
- See Also:
- Constant Field Values
-
HTTP_METHOD_OPTIONS
public static final String HTTP_METHOD_OPTIONS
- See Also:
- Constant Field Values
-
HTTP_METHOD_WEBSOCKET
public static final String HTTP_METHOD_WEBSOCKET
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Route
public Route(String httpMethod, String uri, Method controllerMethod, FilterChain filterChain)
-
-
Method Detail
-
getUrl
public String getUrl()
Deprecated.Use getUri()
-
getHttpMethod
public String getHttpMethod()
-
isHttpMethod
public boolean isHttpMethod(String method)
-
isHttpMethodGet
public boolean isHttpMethodGet()
-
isHttpMethodPost
public boolean isHttpMethodPost()
-
isHttpMethodPut
public boolean isHttpMethodPut()
-
isHttpMethodDelete
public boolean isHttpMethodDelete()
-
isHttpMethodHead
public boolean isHttpMethodHead()
-
isHttpMethodOptions
public boolean isHttpMethodOptions()
-
isHttpMethodWebSocket
public boolean isHttpMethodWebSocket()
-
getUri
public String getUri()
-
getControllerClass
public Class<?> getControllerClass()
-
getControllerMethod
public Method getControllerMethod()
-
getFilterChain
public FilterChain getFilterChain()
-
getParameters
public Map<String,RouteParameter> getParameters()
-
matches
public boolean matches(String httpMethod, String uri)
Matches /index to /index or /me/1 to /person/{id}- Returns:
- True if the actual route matches a raw rout. False if not.
-
getPathParametersEncoded
public Map<String,String> getPathParametersEncoded(String uri)
This method does not do any decoding / encoding. If you want to decode you have to do it yourself. Most likely with: http://docs.oracle.com/javase/6/docs/api/java/net/URI.html- Parameters:
uri
- The whole encoded uri.- Returns:
- A map with all parameters of that uri. Encoded in => encoded out.
-
convertRawUriToRegex
protected static String convertRawUriToRegex(String rawUri)
Gets a raw uri like "/{name}/id/*" and returns "/([^/]*)/id/*." Also handles regular expressions if defined inside routes: For instance "/users/{username: [a-zA-Z][a-zA-Z_0-9]}" becomes "/users/([a-zA-Z][a-zA-Z_0-9])"- Returns:
- The converted regex with default matching regex - or the regex specified by the user.
-
-