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 TypeMethodDescriptiondefault RoutingResult
apply(RoutingContext routingCtx)
Deprecated.apply(RoutingContext routingCtx, boolean isRouteDecorator)
Matches the specifiedRoutingContext
and extracts the path parameters from it if exists.static RouteBuilder
builder()
Returns a new builder.int
Returns the complexity of thisRoute
.consumes()
boolean
methods()
static Route
Returns the catch-allRoute
which matches every request.Returns the names of the path parameters extracted by this mapping.paths()
Returns the list of paths that thisRoute
has.pathType()
Returns the type of the path which was specified when this is created.Returns the path pattern of thisRoute
.produces()
Returns a newRouteBuilder
with the values of thisRoute
instance.
-
Method Details
-
ofCatchAll
Returns the catch-allRoute
which matches every request. -
builder
Returns a new builder. -
apply
Deprecated.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)
-
apply
Matches the specifiedRoutingContext
and extracts the path parameters from it if exists.- Parameters:
routingCtx
- a context to find theHttpService
isRouteDecorator
-true
if this method is called for route decorators.false
if this method is called for services. Iftrue
, anHttpStatusException
will not be deferred and preflight request will not be handled by thisRoute
.- 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
-
isFallback
boolean isFallback() -
excludedRoutes
-
toBuilder
RouteBuilder toBuilder()Returns a newRouteBuilder
with the values of thisRoute
instance.
-
apply(RoutingContext, boolean)
.