Package spark.route
Class Routes
java.lang.Object
spark.route.Routes
- Direct Known Subclasses:
SimpleRouteMatcher
Holds the routes and performs matching from HTTP requests to routes.
Works as Sinatra's, ie. if there are more than one match the one that was mapped first is chosen.
- Author:
- Per Wendel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voidadd(HttpMethod httpMethod, FilterImpl filter) Add a filtervoidadd(HttpMethod httpMethod, RouteImpl route) Add a routevoidclear()¨Clear all routesstatic Routescreate()find(HttpMethod httpMethod, String path, String acceptType) finds target for a requested routefindAll()findMultiple(HttpMethod httpMethod, String path, String acceptType) Finds multiple targets for a requested route.booleanRemoves a particular route from the collection of those that have been previously routed.booleanRemoves a particular route from the collection of those that have been previously routed.
-
Constructor Details
-
Routes
protected Routes()Constructor
-
-
Method Details
-
create
-
add
Add a route- Parameters:
httpMethod- the http-method of the routeroute- the route to add
-
add
Add a filter- Parameters:
httpMethod- the http-method of the routefilter- the filter to add
-
find
finds target for a requested route- Parameters:
httpMethod- the http methodpath- the pathacceptType- the accept type- Returns:
- the target
-
findMultiple
Finds multiple targets for a requested route.- Parameters:
httpMethod- the http methodpath- the route pathacceptType- the accept type- Returns:
- the targets
-
findAll
- Returns:
- the targets
-
clear
public void clear()¨Clear all routes -
remove
Removes a particular route from the collection of those that have been previously routed. Search for a previously established routes using the given path and HTTP method, removing any matches that are found.- Parameters:
path- the route pathhttpMethod- the http method- Returns:
- true if this a matching route has been previously routed
- Throws:
IllegalArgumentException- if path is null or blank or if httpMethod is null, blank or an invalid HTTP method- Since:
- 2.2
-
remove
Removes a particular route from the collection of those that have been previously routed. Search for a previously established routes using the given path and removes any matches that are found.- Parameters:
path- the route path- Returns:
- true if this a matching route has been previously routed
- Throws:
IllegalArgumentException- if path is null or blank- Since:
- 2.2
-
add
Deprecated.Parse and validates a route and adds it- Parameters:
route- the route pathacceptType- the accept typetarget- the invocation target
-