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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private List
<RouteEntry> private static final char
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.private void
add
(HttpMethod method, String url, String acceptedType, Object target) void
add
(HttpMethod httpMethod, FilterImpl filter) Add a filtervoid
add
(HttpMethod httpMethod, RouteImpl route) Add a routevoid
clear()
¨Clear all routesstatic Routes
create()
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.private List
<RouteEntry> findTargetsForRequestedRoute
(HttpMethod httpMethod, String path) private RouteEntry
findTargetWithGivenAcceptType
(List<RouteEntry> routeMatches, String acceptType) private Map
<String, RouteEntry> getAcceptedMimeTypes
(List<RouteEntry> routes) boolean
Removes a particular route from the collection of those that have been previously routed.boolean
Removes a particular route from the collection of those that have been previously routed.private boolean
removeRoute
(HttpMethod httpMethod, String path) private boolean
routeWithGivenAcceptType
(String bestMatch)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
SINGLE_QUOTE
private static final char SINGLE_QUOTE- See Also:
-
routes
-
-
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
-
getAcceptedMimeTypes
-
routeWithGivenAcceptType
-
findTargetsForRequestedRoute
-
findTargetWithGivenAcceptType
-
removeRoute
-
add
Deprecated.Parse and validates a route and adds it- Parameters:
route
- the route pathacceptType
- the accept typetarget
- the invocation target
-