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 RoutingResultapply(RoutingContext routingCtx) Deprecated.apply(RoutingContext routingCtx, boolean isRouteDecorator) Matches the specifiedRoutingContextand extracts the path parameters from it if exists.static RouteBuilderbuilder()Returns a new builder.intReturns the complexity of thisRoute.consumes()booleanbooleanmethods()static RouteReturns the catch-allRoutewhich matches every request.Returns the names of the path parameters extracted by this mapping.paths()Returns the list of paths that thisRoutehas.pathType()Returns the type of the path which was specified when this is created.Returns the path pattern of thisRoute.produces()Returns a newRouteBuilderwith the values of thisRouteinstance.withPrefix(String prefix)
-
Method Details
-
ofCatchAll
Returns the catch-allRoutewhich matches every request. -
builder
Returns a new builder. -
apply
Deprecated.Matches the specifiedRoutingContextand extracts the path parameters from it if exists.- Parameters:
routingCtx- a context to find theHttpService- Returns:
- a non-empty
RoutingResultif the path, method, contentType and acceptTypes and HTTP headers and query parameters matches the equivalent conditions inRoute.RoutingResult.empty()otherwise. - See Also:
-
apply
Matches the specifiedRoutingContextand extracts the path parameters from it if exists.- Parameters:
routingCtx- a context to find theHttpServiceisRouteDecorator-trueif this method is called for route decorators.falseif this method is called for services. Iftrue, anHttpStatusExceptionwill not be deferred and preflight request will not be handled by thisRoute.- Returns:
- a non-empty
RoutingResultif the path, method, contentType and acceptTypes and HTTP headers and query parameters matches the equivalent conditions inRoute.RoutingResult.empty()otherwise. - See Also:
-
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 theRoutewas created usingRouteBuilder.glob(String)"^/(?(.+)/)?foo$"if theRoutewas 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 thisRoutehas. 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.PREFIXandRoutePathType.PARAMETERIZEDhave 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.REGEXmay have one or two paths. If theRoutewas 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_PREFIXhas 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 newRouteBuilderwith the values of thisRouteinstance. -
withPrefix
Returns a newly-createdRoutewhich adds the specifiedprefixto thisRoute. These are examples of createdRoutes when the prefix is/api/v1:/login->/api/v1/login/users/{userId}->/api/v1/users/{userId}prefix:/files->prefix:/api/v1/files(prefix match)regex:^/files/(?<filePath>.*)$->regex:^/api/v1/files/(?<filePath>.*)$(regular expression)
-
isCacheable
boolean isCacheable()
-
apply(RoutingContext, boolean).