Package com.linecorp.armeria.server
Class RouteBuilder
java.lang.Object
com.linecorp.armeria.server.RouteBuilder
Builds a new
Route
.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newly-createdRoute
based on the properties of this builder.catchAll()
Sets theRoute
to match any path.boolean
Sets theRoute
to match the specified exact path.Sets theRoute
to match the specifiedglob
.int
hashCode()
matchesHeaders
(CharSequence headerName, Predicate<? super String> valuePredicate) Sets theRoute
to accept a request when the specifiedvaluePredicate
evaluatestrue
with the value of the specifiedheaderName
header.matchesHeaders
(Iterable<String> headerPredicates) Sets theRoute
to accept a request if it matches all the specified predicates forHttpHeaders
.matchesHeaders
(String... headerPredicates) Sets theRoute
to accept a request if it matches all the specified predicates forHttpHeaders
.matchesParams
(Iterable<String> paramPredicates) Sets theRoute
to accept a request if it matches all the specified predicates for HTTP parameters.matchesParams
(String... paramPredicates) Sets theRoute
to accept a request if it matches all the specified predicates for HTTP parameters.matchesParams
(String paramName, Predicate<? super String> valuePredicate) Sets theRoute
to accept a request when the specifiedvaluePredicate
evaluatestrue
with the value of the specifiedparamName
parameter.methods
(HttpMethod... methods) Sets theRoute
to support the specifiedHttpMethod
s.methods
(Iterable<HttpMethod> methods) Sets theRoute
to support the specifiedHttpMethod
s.Sets theRoute
to match the specifiedpathPattern
. e.g.pathPrefix
(String prefix) pathPrefix
(String prefix, boolean stripPrefix) Sets theRoute
to match the specifiedregex
.Sets theRoute
to match the specifiedregex
.toString()
-
Method Details
-
path
Sets theRoute
to match the specifiedpathPattern
. e.g./login
(no path parameters)/users/{userId}
(curly-brace style)/list/:productType/by/:ordering
(colon style)exact:/foo/bar
(exact match)prefix:/files
(prefix match)glob:/~*/downloads/**
(glob pattern)regex:^/files/(?<filePath>.*)$
(regular expression)
- Throws:
IllegalArgumentException
- if the specified path pattern is invalid
-
path
Sets theRoute
to match the specifiedprefix
andpathPattern
. The mappedHttpService
is found when a path is under the specifiedprefix
and the rest of the path matches the specifiedpathPattern
.- See Also:
-
exact
Sets theRoute
to match the specified exact path. -
pathPrefix
Sets theRoute
to match when a path is under the specifiedprefix
. It also removes the specifiedprefix
from the matched path so that mappedPath does not have the specifiedprefix
. For example, whenprefix
is"/foo/"
:"/foo/"
translates to"/"
"/foo/bar"
translates to"/bar"
"/foo/bar/baz"
translates to"/bar/baz"
-
pathPrefix
Sets theRoute
to match when a path is under the specifiedprefix
. WhenstripPrefix
istrue
, it also removes the specifiedprefix
from the matched path so that mappedPath does not have the specifiedprefix
. For example, whenprefix
is"/foo/"
:"/foo/"
translates to"/"
"/foo/bar"
translates to"/bar"
"/foo/bar/baz"
translates to"/bar/baz"
-
catchAll
Sets theRoute
to match any path. -
glob
Sets theRoute
to match the specifiedglob
."*"
in the expression matches a path component non-recursively whereas"**"
matches path components recursively. -
regex
Sets theRoute
to match the specifiedregex
. It also extracts the values of the named groups to pathParams: e.g."^/users/(?<userId>[0-9]+)$"
will extract the second numeric part of the path into the"userId"
path parameter. -
regex
Sets theRoute
to match the specifiedregex
. It also extracts the values of the named groups to pathParams: e.g."^/users/(?<userId>[0-9]+)$"
will extract the second numeric part of the path into the"userId"
path parameter. -
methods
Sets theRoute
to support the specifiedHttpMethod
s. If not set, the mappedHttpService
accepts anyHttpMethod
s. -
methods
Sets theRoute
to support the specifiedHttpMethod
s. If not set, the mappedHttpService
accepts anyHttpMethod
s. -
consumes
Sets theRoute
to consume the specifiedMediaType
s. If not set, the mappedHttpService
acceptsHttpRequest
s that have anyHttpHeaderNames.CONTENT_TYPE
. In order to get this work,methods(Iterable)
must be set. -
consumes
Sets theRoute
to consume the specifiedMediaType
s. If not set, the mappedHttpService
acceptsHttpRequest
s that have anyHttpHeaderNames.CONTENT_TYPE
. In order to get this work,methods(Iterable)
must be set. -
produces
Sets theRoute
to produce the specifiedMediaType
s. If not set, the mappedHttpService
acceptsHttpRequest
s that have anyHttpHeaderNames.ACCEPT
. In order to get this work,methods(Iterable)
must be set. -
produces
Sets theRoute
to produce the specifiedMediaType
s. If not set, the mappedHttpService
acceptsHttpRequest
s that have anyHttpHeaderNames.ACCEPT
. In order to get this work,methods(Iterable)
must be set. -
matchesParams
Sets theRoute
to accept a request if it matches all the specified predicates for HTTP parameters. The predicate can be one of the following forms:some-param=some-value
which means that the request must have asome-param=some-value
parametersome-param!=some-value
which means that the request must not have asome-param=some-value
parametersome-param
which means that the request must contain asome-param
parameter!some-param
which means that the request must not contain asome-param
parameter
Note that these predicates can be evaluated only with the query string of the request URI. Also note that each predicate will be evaluated with the decoded value of HTTP parameters, so do not use percent-encoded value in the predicate.
- See Also:
-
matchesParams
Sets theRoute
to accept a request if it matches all the specified predicates for HTTP parameters. The predicate can be one of the following forms:some-param=some-value
which means that the request must have asome-param=some-value
parametersome-param!=some-value
which means that the request must not have asome-param=some-value
parametersome-param
which means that the request must contain asome-param
parameter!some-param
which means that the request must not contain asome-param
parameter
Note that these predicates can be evaluated only with the query string of the request URI. Also note that each predicate will be evaluated with the decoded value of HTTP parameters, so do not use percent-encoded value in the predicate.
- See Also:
-
matchesParams
Sets theRoute
to accept a request when the specifiedvaluePredicate
evaluatestrue
with the value of the specifiedparamName
parameter. -
matchesHeaders
Sets theRoute
to accept a request if it matches all the specified predicates forHttpHeaders
. The predicate can be one of the following forms:some-header=some-value
which means that the request must have asome-header: some-value
headersome-header!=some-value
which means that the request must not have asome-header: some-value
headersome-header
which means that the request must contain asome-header
header!some-header
which means that the request must not contain asome-header
header
- See Also:
-
matchesHeaders
Sets theRoute
to accept a request if it matches all the specified predicates forHttpHeaders
. The predicate can be one of the following forms:some-header=some-value
which means that the request must have asome-header: some-value
headersome-header!=some-value
which means that the request must not have asome-header: some-value
an headersome-header
which means that the request must contain asome-header
header!some-header
which means that the request must not contain asome-header
header
- See Also:
-
matchesHeaders
public RouteBuilder matchesHeaders(CharSequence headerName, Predicate<? super String> valuePredicate) Sets theRoute
to accept a request when the specifiedvaluePredicate
evaluatestrue
with the value of the specifiedheaderName
header. -
build
Returns a newly-createdRoute
based on the properties of this builder. -
hashCode
public int hashCode() -
equals
-
toString
-