Package com.linecorp.armeria.server
Interface RoutingContext
public interface RoutingContext
Holds the parameters which are required to find a service available to handle the request.
-
Method Summary
Modifier and TypeMethodDescriptionReturns a list ofMediaType
s that are specified inHttpHeaderNames.ACCEPT
in the order of client-side preferences.ReturnsMediaType
specified by 'Content-Type' header of the request.Returns a deferredHttpStatusException
which was previously set viadeferStatusException(HttpStatusException)
.void
Defers throwing anHttpStatusException
until reaching the end of the service list.boolean
Returnstrue
if a routing result is set.headers()
Returns theRequestHeaders
retrieved from the request.hostname()
Returns the virtual host name of the request.boolean
Deprecated.method()
ReturnsHttpMethod
of the request.default RoutingContext
overridePath
(String path) Deprecated.UsewithPath(String)
.params()
Returns the query parameters retrieved from the request path.default String
path()
Returns the absolute path retrieved from the request, as defined in RFC3986.query()
Returns the query retrieved from the request, as defined in RFC3986.Returns theRequestTarget
of the request.default boolean
Returnstrue
if this context requires matching the predicates for HTTP headers.default boolean
Returnstrue
if this context requires matching the predicates for query parameters.result()
Returns the routing result of thisRoutingContext
.void
setResult
(Routed<ServiceConfig> result) Sets the routing result to thisRoutingContext
.status()
Returns theRoutingStatus
of the request.Returns theVirtualHost
instance which belongs to thisRoutingContext
.default RoutingContext
withMethod
(HttpMethod method) Returns a wrappedRoutingContext
which holds the specifiedHttpMethod
.default RoutingContext
(Advanced users only) Returns a wrappedRoutingContext
which holds the specifiedpath
.
-
Method Details
-
virtualHost
VirtualHost virtualHost()Returns theVirtualHost
instance which belongs to thisRoutingContext
. -
hostname
String hostname()Returns the virtual host name of the request. -
method
HttpMethod method()ReturnsHttpMethod
of the request. -
withMethod
Returns a wrappedRoutingContext
which holds the specifiedHttpMethod
. -
requestTarget
RequestTarget requestTarget()Returns theRequestTarget
of the request. The form of the returnedRequestTarget
is neverRequestTargetForm.ABSOLUTE
, which means it is alwaysRequestTargetForm.ORIGIN
orRequestTargetForm.ASTERISK
. -
path
Returns the absolute path retrieved from the request, as defined in RFC3986. -
query
Returns the query retrieved from the request, as defined in RFC3986. -
params
QueryParams params()Returns the query parameters retrieved from the request path. -
contentType
ReturnsMediaType
specified by 'Content-Type' header of the request. -
acceptTypes
Returns a list ofMediaType
s that are specified inHttpHeaderNames.ACCEPT
in the order of client-side preferences. If the client does not send the header, this will contain onlyMediaType.ANY_TYPE
. -
headers
RequestHeaders headers()Returns theRequestHeaders
retrieved from the request. -
status
Returns theRoutingStatus
of the request. -
deferStatusException
Defers throwing anHttpStatusException
until reaching the end of the service list. -
deferredStatusException
Returns a deferredHttpStatusException
which was previously set viadeferStatusException(HttpStatusException)
. -
withPath
(Advanced users only) Returns a wrappedRoutingContext
which holds the specifiedpath
. It is usually used to find anHttpService
with a prefix-stripped path. Note that specifying a malformed or relative path will lead to unspecified behavior. -
overridePath
Deprecated.UsewithPath(String)
.Returns a wrappedRoutingContext
which holds the specifiedpath
. It is usually used to find anHttpService
with a prefix-stripped path. -
isCorsPreflight
Deprecated.Usestatus()
andRoutingStatus.CORS_PREFLIGHT
.Returnstrue
if this context is for a CORS preflight request. -
requiresMatchingParamsPredicates
default boolean requiresMatchingParamsPredicates()Returnstrue
if this context requires matching the predicates for query parameters.- See Also:
-
requiresMatchingHeadersPredicates
default boolean requiresMatchingHeadersPredicates()Returnstrue
if this context requires matching the predicates for HTTP headers.- See Also:
-
hasResult
Returnstrue
if a routing result is set. -
setResult
Sets the routing result to thisRoutingContext
.Note that the result is automatically set when this
RoutingContext
finds a matchedServiceConfig
from aRouter
. Don't set aresult
manually unless you really intend it.- Throws:
IllegalStateException
- if aRouted
is set already.
-
result
Returns the routing result of thisRoutingContext
.- Throws:
IllegalStateException
- if the result has not resolved yet.
-
status()
andRoutingStatus.CORS_PREFLIGHT
.