Package com.linecorp.armeria.server
Interface Route
public interface Route
Route
maps from an incoming HTTP request to an HttpService
based on its path, method,
content type and accepted types.-
Method Summary
Modifier and Type Method Description RoutingResult
apply(RoutingContext routingCtx)
Matches the specifiedRoutingContext
and extracts the path parameters from it if exists.static RouteBuilder
builder()
Returns a new builder.int
complexity()
Returns the complexity of thisRoute
.Set<MediaType>
consumes()
Set<HttpMethod>
methods()
static Route
ofCatchAll()
Returns the catch-allRoute
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 thisRoute
has.RoutePathType
pathType()
Returns the type of the path which was specified when this is created.String
patternString()
Returns the path pattern of thisRoute
.Set<MediaType>
produces()
-
Method Details
-
ofCatchAll
Returns the catch-allRoute
which matches every request. -
builder
Returns a new builder. -
apply
Matches the specifiedRoutingContext
and extracts the path parameters from it if exists.- Parameters:
routingCtx
- a context to find theHttpService
- Returns:
- a non-empty
RoutingResult
if the path, method, contentType and acceptTypes and HTTP headers and query parameters matches the equivalent conditions inRoute
.RoutingResult.empty()
otherwise. - See Also:
RouteBuilder.methods(Iterable)
,RouteBuilder.consumes(Iterable)
,RouteBuilder.produces(Iterable)
,RouteBuilder.matchesHeaders(Iterable)
,RouteBuilder.matchesParams(Iterable)
-
paramNames
Returns the names of the path parameters extracted by this mapping. -
patternString
String patternString()Returns the path pattern of thisRoute
. The returned path pattern is different according to the value ofpathType()
.- EXACT:
"/foo"
or"/foo/bar"
- PREFIX:
"/foo/*"
- PARAMETERIZED:
"/foo/:bar"
or"/foo/:bar/:qux
- REGEX may have a glob pattern or a regular expression:
"/**/foo"
if theRoute
was created usingRouteBuilder.glob(String)
"^/(?(.+)/)?foo$"
if theRoute
was created usingRouteBuilder.regex(String)
- REGEX_WITH_PREFIX may have a glob pattern or a regular expression with a prefix:
- EXACT:
-
pathType
RoutePathType pathType()Returns the type of the path which was specified when this is created. -
paths
Returns the list of paths that thisRoute
has. The paths are different according to the value ofpathType()
. 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
andRoutePathType.PARAMETERIZED
have the trie path.- EXACT:
[ "/foo", "/foo" ]
(The trie path is the same.) - PREFIX:
[ "/foo/", "/foo/*" ]
- PARAMETERIZED:
[ "/foo/:", "/foo/:" ]
(The trie path is the same.)
RoutePathType.REGEX
may have one or two paths. If theRoute
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/" ]
- EXACT:
-
complexity
int complexity()Returns the complexity of thisRoute
. A higher complexity indicates more expensive computation for route matching, usually due to additional number of checks. -
methods
Set<HttpMethod> methods() -
consumes
-
produces
-