public interface Route
Route maps from an incoming HTTP request to an HttpService based on its path, method,
content type and accepted types.| Modifier and Type | Method and Description |
|---|---|
RoutingResult |
apply(RoutingContext routingCtx)
Matches the specified
RoutingContext and extracts the path parameters from it if exists. |
static RouteBuilder |
builder()
Returns a new builder.
|
int |
complexity()
Returns the complexity of this
Route. |
Set<MediaType> |
consumes()
|
String |
loggerName()
Returns the logger name.
|
String |
meterTag()
|
Set<HttpMethod> |
methods()
|
static Route |
ofCatchAll()
Returns the catch-all
Route which matches every request. |
Set<String> |
paramNames()
Returns the names of the path parameters extracted by this mapping.
|
List<String> |
paths()
Returns the list of paths that this
Route has. |
RoutePathType |
pathType()
Returns the type of the path which was specified when this is created.
|
Set<MediaType> |
produces()
|
static RouteBuilder builder()
RoutingResult apply(RoutingContext routingCtx)
RoutingContext and extracts the path parameters from it if exists.routingCtx - a context to find the HttpServiceRoutingResult if the path,
method,
contentType and
acceptTypes and
HTTP headers and
query parameters matches the equivalent conditions in
Route. RoutingResult.empty() otherwise.RouteBuilder.methods(Iterable),
RouteBuilder.consumes(Iterable),
RouteBuilder.produces(Iterable),
RouteBuilder.matchesHeaders(Iterable),
RouteBuilder.matchesParams(Iterable)Set<String> paramNames()
String loggerName()
String meterTag()
RoutePathType pathType()
List<String> paths()
Route has. The paths are different according to the value
of pathType(). If the path type has a trie path,
this method will return a two-element list whose first element is the path that represents the type and
the second element is the trie path. RoutePathType.EXACT, RoutePathType.PREFIX and
RoutePathType.PARAMETERIZED have the trie path.
[ "/foo", "/foo" ] (The trie path is the same.)[ "/foo/", "/foo/*" ][ "/foo/:", "/foo/:" ] (The trie path is the same.)RoutePathType.REGEX may have one or two paths. If the Route was created from a glob
pattern, it will have two paths where the first one is the regular expression and the second one
is the glob pattern, e.g. [ "^/(?(.+)/)?foo$", "/**/foo" ].
If not created from a glob pattern, it will have only one path, which is the regular expression,
e.g, [ "^/(?<foo>.*)$" ]
RoutePathType.REGEX_WITH_PREFIX has two paths. The first one is the regex and the second
one is the path. e.g, [ "^/(?<foo>.*)$", "/bar/" ]
int complexity()
Route. A higher complexity indicates more expensive computation
for route matching, usually due to additional number of checks.Set<HttpMethod> methods()
Copyright © 2020 LeanCloud. All rights reserved.