Package ninja
Interface Router
-
- All Known Implementing Classes:
RouterImpl
public interface Router
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
compileRoutes()
Compile all the routes that have been registered with the router.RouteBuilder
DELETE()
RouteBuilder
GET()
String
getReverseRoute(Class<?> clazz, String methodName)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(Class<?> clazz, String methodName, Object... parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(Class<?> clazz, String methodName, Map<String,Object> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(Class<?> controllerClass, String controllerMethodName, Optional<Map<String,Object>> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(MethodReference controllerMethodRef)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(MethodReference controllerMethodRef, Object... parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(MethodReference controllerMethodRef, Map<String,Object> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.String
getReverseRoute(MethodReference controllerMethodRef, Optional<Map<String,Object>> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters.Route
getRouteFor(String httpMethod, String uri)
Get the route for the given method and URIOptional<Route>
getRouteForControllerClassAndMethod(Class<?> controllerClass, String controllerMethodName)
List<Route>
getRoutes()
Returns the list of compiled routes.RouteBuilder
HEAD()
RouteBuilder
METHOD(String method)
To match any http method.RouteBuilder
OPTIONS()
RouteBuilder
POST()
RouteBuilder
PUT()
RouteBuilder
WS()
-
-
-
Method Detail
-
getRouteFor
Route getRouteFor(String httpMethod, String uri)
Get the route for the given method and URI- Parameters:
httpMethod
- The methoduri
- The URI- Returns:
- The route
-
getReverseRoute
@Deprecated String getReverseRoute(Class<?> clazz, String methodName)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.Retrieves the reverse route for this controllerClass and method. Does not work with routes that contain placeholders. UsegetReverseRoute(Class, String, Map)
in that case- Parameters:
clazz
- The controllerClass e.g. ApplicationController.classmethodName
- the methodName of the class e.g. "index"- Returns:
- The final url (without server, and without any prefixes)
-
getReverseRoute
@Deprecated String getReverseRoute(Class<?> clazz, String methodName, Map<String,Object> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.Retrieves the reverse route for this controllerClass and method. The map contains pairs of url parameters. Eg. a raw route like "/person/{id} will become /person/1 when the map contains a pair like "id, "1".- Parameters:
clazz
- The controllerClass e.g. ApplicationController.classmethodName
- the methodName of the class e.g. "index"map
- The map containing pairs with replacements for placeholders. It's a String Object map so that it matches the map used to render a page. to get the value "toString()" is called on the object. Make sure that works for your object or simply use a String. If the raw uri does not contain the placeholders they will be added as query parameters ?key=value&key2=value2 and so on- Returns:
- The final url (without server, and without any prefixes)
-
getReverseRoute
@Deprecated String getReverseRoute(Class<?> clazz, String methodName, Object... parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.Retrieves the reverse route for this controllerClass and method. The map contains pairs of url parameters. Eg. a raw route like "/person/{id} will become /person/1 when the map contains a pair like "id, "1".- Parameters:
clazz
- The controllerClass e.g. ApplicationController.classmethodName
- the methodName of the class e.g. "index"parameterMap
- The map containing pairs with replacements for placeholders. Always supply key and value pairs. Key as strings, Values as objects. To get the value "toString()" is called on the object. Make sure that works for your object or simply use a String. If the raw uri does not contain the placeholders they will be added as query parameters ?key=value&key2=value2 and so on- Returns:
- The final url (without server, and without any prefixes)
-
getReverseRoute
@Deprecated String getReverseRoute(Class<?> controllerClass, String controllerMethodName, Optional<Map<String,Object>> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.Retrieves the reverse route for this controllerClass and method. The map contains pairs of url parameters. Eg. a raw route like "/person/{id} will become /person/1 when the map contains a pair like "id, "1".- Parameters:
clazz
- The controllerClass e.g. ApplicationController.classmethodName
- the methodName of the class e.g. "index"parameterMap
- An optinal map containing pairs with replacements for placeholders. Always supply key and value pairs. Key as strings, Values as objects. To get the value "toString()" is called on the object. Make sure that works for your object or simply use a String. If the raw uri does not contain the placeholders they will be added as query parameters ?key=value&key2=value2 and so on- Returns:
- The final url (without server, and without any prefixes)
-
getReverseRoute
@Deprecated String getReverseRoute(MethodReference controllerMethodRef)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.
-
getReverseRoute
@Deprecated String getReverseRoute(MethodReference controllerMethodRef, Map<String,Object> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.
-
getReverseRoute
@Deprecated String getReverseRoute(MethodReference controllerMethodRef, Object... parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.
-
getReverseRoute
@Deprecated String getReverseRoute(MethodReference controllerMethodRef, Optional<Map<String,Object>> parameterMap)
Deprecated.Reverse routing in the Router is not validated and does not URL-escape path or query parameters. Useninja.ReverseRouter
to build your reverse routes.
-
compileRoutes
void compileRoutes()
Compile all the routes that have been registered with the router. This should be called once, during initialization, before the application starts serving requests.
-
getRouteForControllerClassAndMethod
Optional<Route> getRouteForControllerClassAndMethod(Class<?> controllerClass, String controllerMethodName)
-
GET
RouteBuilder GET()
-
POST
RouteBuilder POST()
-
PUT
RouteBuilder PUT()
-
DELETE
RouteBuilder DELETE()
-
OPTIONS
RouteBuilder OPTIONS()
-
HEAD
RouteBuilder HEAD()
-
WS
RouteBuilder WS()
-
METHOD
RouteBuilder METHOD(String method)
To match any http method. E.g. METHOD("PROPFIND") would route PROPFIND methods.- Parameters:
method
- The http method like "GET" or "PROPFIND"- Returns:
- the routeBuilder for chaining.
-
-