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 ofMediaTypes that are specified inHttpHeaderNames.ACCEPTin the order of client-side preferences.ReturnsMediaTypespecified by 'Content-Type' header of the request.Returns a deferredHttpStatusExceptionwhich was previously set viadeferStatusException(HttpStatusException).voidDefers throwing anHttpStatusExceptionuntil reaching the end of the service list.booleanReturnstrueif a routing result is set.headers()Returns theRequestHeadersretrieved from the request.hostname()Returns the virtual host name of the request.booleanDeprecated.method()ReturnsHttpMethodof the request.default RoutingContextoverridePath(String path) Deprecated.UsewithPath(String).params()Returns the query parameters retrieved from the request path.default Stringpath()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 theRequestTargetof the request.default booleanReturnstrueif this context requires matching the predicates for HTTP headers.default booleanReturnstrueif this context requires matching the predicates for query parameters.result()Returns the routing result of thisRoutingContext.voidsetResult(Routed<ServiceConfig> result) Sets the routing result to thisRoutingContext.status()Returns theRoutingStatusof the request.Returns theVirtualHostinstance which belongs to thisRoutingContext.default RoutingContextwithMethod(HttpMethod method) Returns a wrappedRoutingContextwhich holds the specifiedHttpMethod.default RoutingContext(Advanced users only) Returns a wrappedRoutingContextwhich holds the specifiedpath.
-
Method Details
-
virtualHost
VirtualHost virtualHost()Returns theVirtualHostinstance which belongs to thisRoutingContext. -
hostname
String hostname()Returns the virtual host name of the request. -
method
HttpMethod method()ReturnsHttpMethodof the request. -
withMethod
Returns a wrappedRoutingContextwhich holds the specifiedHttpMethod. -
requestTarget
RequestTarget requestTarget()Returns theRequestTargetof the request. The form of the returnedRequestTargetis neverRequestTargetForm.ABSOLUTE, which means it is alwaysRequestTargetForm.ORIGINorRequestTargetForm.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
ReturnsMediaTypespecified by 'Content-Type' header of the request. -
acceptTypes
Returns a list ofMediaTypes that are specified inHttpHeaderNames.ACCEPTin the order of client-side preferences. If the client does not send the header, this will contain onlyMediaType.ANY_TYPE. -
headers
RequestHeaders headers()Returns theRequestHeadersretrieved from the request. -
status
Returns theRoutingStatusof the request. -
deferStatusException
Defers throwing anHttpStatusExceptionuntil reaching the end of the service list. -
deferredStatusException
Returns a deferredHttpStatusExceptionwhich was previously set viadeferStatusException(HttpStatusException). -
withPath
(Advanced users only) Returns a wrappedRoutingContextwhich holds the specifiedpath. It is usually used to find anHttpServicewith a prefix-stripped path. Note that specifying a malformed or relative path will lead to unspecified behavior. -
overridePath
Deprecated.UsewithPath(String).Returns a wrappedRoutingContextwhich holds the specifiedpath. It is usually used to find anHttpServicewith a prefix-stripped path. -
isCorsPreflight
Deprecated.Usestatus()andRoutingStatus.CORS_PREFLIGHT.Returnstrueif this context is for a CORS preflight request. -
requiresMatchingParamsPredicates
default boolean requiresMatchingParamsPredicates()Returnstrueif this context requires matching the predicates for query parameters.- See Also:
-
requiresMatchingHeadersPredicates
default boolean requiresMatchingHeadersPredicates()Returnstrueif this context requires matching the predicates for HTTP headers.- See Also:
-
hasResult
Returnstrueif a routing result is set. -
setResult
Sets the routing result to thisRoutingContext.Note that the result is automatically set when this
RoutingContextfinds a matchedServiceConfigfrom aRouter. Don't set aresultmanually unless you really intend it.- Throws:
IllegalStateException- if aRoutedis set already.
-
result
Returns the routing result of thisRoutingContext.- Throws:
IllegalStateException- if the result has not resolved yet.
-
status()andRoutingStatus.CORS_PREFLIGHT.