public interface ServiceRequestContext extends RequestContext
ServiceRequestContext
instance.Modifier and Type | Method and Description |
---|---|
ExecutorService |
blockingTaskExecutor()
Returns the
ExecutorService that could be used for executing a potentially long-running task. |
Logger |
logger()
Deprecated.
Use a logging framework integration such as
RequestContextExportingAppender in
armeria-logback . |
String |
mappedPath()
Returns the path with its context path removed.
|
long |
maxRequestLength()
Returns the maximum length of the current
Request . |
MediaType |
negotiatedProduceType()
Returns the negotiated producible media type.
|
PathMapping |
pathMapping()
|
PathMappingContext |
pathMappingContext()
Returns the
PathMappingContext used to find the Service . |
default String |
pathParam(String name)
Returns the value of the specified path parameter.
|
Map<String,String> |
pathParams()
Returns the path parameters mapped by the
PathMapping associated with the Service
that is handling the current Request . |
long |
requestTimeoutMillis()
Returns the amount of time allowed until receiving the current
Request completely. |
Server |
server()
|
<T extends Service<HttpRequest,HttpResponse>> |
service()
|
void |
setMaxRequestLength(long maxRequestLength)
Sets the maximum length of the current
Request . |
void |
setRequestTimeout(Duration requestTimeout)
Sets the amount of time allowed until receiving the current
Request completely. |
void |
setRequestTimeoutHandler(Runnable requestTimeoutHandler)
Sets a handler to run when the request times out.
|
void |
setRequestTimeoutMillis(long requestTimeoutMillis)
Sets the amount of time allowed until receiving the current
Request completely. |
VirtualHost |
virtualHost()
Returns the
VirtualHost that is handling the current Request . |
alloc, attrs, contextAwareEventLoop, current, eventLoop, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, isTimedOut, localAddress, log, logBuilder, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, mapCurrent, meterRegistry, method, onChild, onEnter, onEnter, onExit, onExit, path, push, push, query, rejectPromise, remoteAddress, request, resolvePromise, sessionProtocol, sslSession
attr, hasAttr
Server server()
VirtualHost virtualHost()
VirtualHost
that is handling the current Request
.PathMapping pathMapping()
PathMappingContext pathMappingContext()
PathMappingContext
used to find the Service
.Map<String,String> pathParams()
PathMapping
associated with the Service
that is handling the current Request
.<T extends Service<HttpRequest,HttpResponse>> T service()
ExecutorService blockingTaskExecutor()
ExecutorService
that could be used for executing a potentially long-running task.
The ExecutorService
will propagate the ServiceRequestContext
automatically when running
a task.
Note that performing a long-running task in Service.serve(ServiceRequestContext, Request)
may block the Server
's I/O event loop and thus should be executed in other threads.
String mappedPath()
@Nullable MediaType negotiatedProduceType()
Service
, null
would be returned.@Deprecated Logger logger()
RequestContextExportingAppender
in
armeria-logback
.long requestTimeoutMillis()
Request
completely.
This value is initially set from ServerConfig.defaultRequestTimeoutMillis()
.void setRequestTimeoutMillis(long requestTimeoutMillis)
Request
completely.
This value is initially set from ServerConfig.defaultRequestTimeoutMillis()
.void setRequestTimeout(Duration requestTimeout)
Request
completely.
This value is initially set from ServerConfig.defaultRequestTimeoutMillis()
.void setRequestTimeoutHandler(Runnable requestTimeoutHandler)
requestTimeoutHandler
must close the response,
e.g., by calling HttpResponseWriter.respond(int)
. If not set, the response will be closed with
HttpStatus.SERVICE_UNAVAILABLE
.
For example,
DefaultHttpResponse res = new DefaultHttpResponse();
ctx.setRequestTimeoutHandler(() -> {
res.respond(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, "Request timed out.");
});
...
long maxRequestLength()
Request
.
This value is initially set from ServerConfig.defaultMaxRequestLength()
.ContentTooLargeException
void setMaxRequestLength(long maxRequestLength)
Request
.
This value is initially set from ServerConfig.defaultMaxRequestLength()
.ContentTooLargeException
© Copyright 2015–2017 LINE Corporation. All rights reserved.