Package org.javalite.activeweb
Class RouteBuilder
java.lang.Object
org.javalite.activeweb.RouteBuilder
Instance of this class represents a single custom route configured in the RouteConfig class of the application.
- Author:
- Igor Polevoy
-
Constructor Summary
ModifierConstructorDescriptionprotected
RouteBuilder(String routeConfig)
Used for custom routesprotected
RouteBuilder(AppController controller, String actionName)
Used for tests.protected
RouteBuilder(AppController controller, String actionName, String id)
Used for standard and restful routes. -
Method Summary
Modifier and TypeMethodDescriptionName of action to which a route is mapped in the underscore format.delete()
Specifies that this route is mapped to HTTP DELETE method.get()
Specifies that this route is mapped to HTTP GET method.protected String
protected AppController
Class<? extends AppController>
protected String
getId()
protected String
getUserSegmentName(String segment)
Extracts user segment name from route config.boolean
protected boolean
matches(String requestUri, org.javalite.activeweb.ControllerPath controllerPath, HttpMethod httpMethod)
Returns true if this route matches the request URI, otherwise returns false.options()
Specifies that this route is mapped to HTTP OPTIONS method.patch()
Specifies that this route is mapped to HTTP PATCH method.post()
Specifies that this route is mapped to HTTP POST method.put()
Specifies that this route is mapped to HTTP PUT method.<T extends AppController>
RouteBuilderAllows to wire a route to a controller.toString()
-
Constructor Details
-
RouteBuilder
Used for standard and restful routes.- Parameters:
controller
- controlleractionName
- action nameid
- id
-
RouteBuilder
Used for tests.- Parameters:
controller
- controlleractionName
- action name
-
RouteBuilder
Used for custom routes- Parameters:
routeConfig
- what was specified in the RouteConfig class
-
-
Method Details
-
isWildcard
public boolean isWildcard() -
getWildcardName
-
getWildCardValue
-
getRouteConfig
-
to
Allows to wire a route to a controller.- Parameters:
controllerClass
- class of controller to which a route is mapped- Returns:
- instance of
RouteBuilder
.
-
action
Name of action to which a route is mapped in the underscore format. for example, if the action method of a controller islistTrigger()
, than this argument needs to belist_trigger
.- Parameters:
action
- name of action.- Returns:
- instance of
RouteBuilder
.
-
get
Specifies that this route is mapped to HTTP GET method.- Returns:
- instance of
RouteBuilder
.
-
post
Specifies that this route is mapped to HTTP POST method.- Returns:
- instance of
RouteBuilder
.
-
patch
Specifies that this route is mapped to HTTP PATCH method.- Returns:
- instance of
RouteBuilder
.
-
options
Specifies that this route is mapped to HTTP OPTIONS method.- Returns:
- instance of
RouteBuilder
.
-
put
Specifies that this route is mapped to HTTP PUT method.- Returns:
- instance of
RouteBuilder
.
-
delete
Specifies that this route is mapped to HTTP DELETE method.- Returns:
- instance of
RouteBuilder
.
-
getActionName
-
getId
-
getController
-
matches
protected boolean matches(String requestUri, org.javalite.activeweb.ControllerPath controllerPath, HttpMethod httpMethod) throws ClassLoadExceptionReturns true if this route matches the request URI, otherwise returns false.- Parameters:
requestUri
- incoming URI for request.httpMethod
- HTTP method of the request.- Returns:
- true if this route matches the request URI
- Throws:
ClassLoadException
- in case could not load controller
-
getUserSegmentName
Extracts user segment name from route config. Returns null if no pattern match: {xxx}.- Parameters:
segment
- user segment, such as "{user_id}", "{fav_color}", etc.- Returns:
- the name inside the braces, "user_id", "fav_color", etc. Returns null if no pattern match: {xxx}.
-
getMethods
-
getControllerClass
-
toString
-