public interface ServiceRequestContext extends RequestContext
ServiceRequestContext
instance.Modifier and Type | Method and Description |
---|---|
java.util.concurrent.ExecutorService |
blockingTaskExecutor()
Returns the
ExecutorService that could be used for executing a potentially long-running task. |
<A extends java.net.SocketAddress> |
localAddress()
Returns the local address of this request.
|
org.slf4j.Logger |
logger()
Deprecated.
Use a logging framework integration such as
RequestContextExportingAppender in
armeria-logback . |
java.lang.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.
|
ServiceRequestContext |
newDerivedContext()
Creates a new derived
RequestContext which only the RequestLog
is different from the deriving context. |
ServiceRequestContext |
newDerivedContext(Request request)
Creates a new derived
RequestContext with the specified Request which the
RequestLog is different from the deriving context. |
PathMapping |
pathMapping()
|
PathMappingContext |
pathMappingContext()
Returns the
PathMappingContext used to find the Service . |
default java.lang.String |
pathParam(java.lang.String name)
Returns the value of the specified path parameter.
|
java.util.Map<java.lang.String,java.lang.String> |
pathParams()
Returns the path parameters mapped by the
PathMapping associated with the Service
that is handling the current Request . |
<A extends java.net.SocketAddress> |
remoteAddress()
Returns the remote address of this 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(java.time.Duration requestTimeout)
Sets the amount of time allowed until receiving the current
Request completely. |
void |
setRequestTimeoutHandler(java.lang.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, 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, request, resolvePromise, sessionProtocol, sslSession
@Nonnull <A extends java.net.SocketAddress> A remoteAddress()
remoteAddress
in interface RequestContext
@Nonnull <A extends java.net.SocketAddress> A localAddress()
localAddress
in interface RequestContext
ServiceRequestContext newDerivedContext()
RequestContext
RequestContext
which only the RequestLog
is different from the deriving context. Note that the references of Attribute
s
in the RequestContext.attrs()
are copied as well.newDerivedContext
in interface RequestContext
ServiceRequestContext newDerivedContext(Request request)
RequestContext
RequestContext
with the specified Request
which the
RequestLog
is different from the deriving context.
Note that the references of Attribute
s in the RequestContext.attrs()
are copied as well.newDerivedContext
in interface RequestContext
Server server()
VirtualHost virtualHost()
VirtualHost
that is handling the current Request
.PathMapping pathMapping()
PathMappingContext pathMappingContext()
PathMappingContext
used to find the Service
.java.util.Map<java.lang.String,java.lang.String> pathParams()
PathMapping
associated with the Service
that is handling the current Request
.@Nullable default java.lang.String pathParam(java.lang.String name)
<T extends Service<HttpRequest,HttpResponse>> T service()
java.util.concurrent.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.
java.lang.String mappedPath()
@Nullable MediaType negotiatedProduceType()
Service
, null
would be returned.@Deprecated org.slf4j.Logger logger()
RequestContextExportingAppender
in
armeria-logback
.Logger
of the Service
.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(java.time.Duration requestTimeout)
Request
completely.
This value is initially set from ServerConfig.defaultRequestTimeoutMillis()
.void setRequestTimeoutHandler(java.lang.Runnable requestTimeoutHandler)
requestTimeoutHandler
must close the response,
e.g., by calling StreamWriter.close()
. If not set, the response will be closed with
HttpStatus.SERVICE_UNAVAILABLE
.
For example,
HttpResponseWriter res = HttpResponse.streaming();
ctx.setRequestTimeoutHandler(() -> {
res.write(HttpHeaders.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, "Request timed out."));
res.close();
});
...
long maxRequestLength()
Request
.
This value is initially set from ServerConfig.defaultMaxRequestLength()
.
If 0, there is no limit on the request size.ContentTooLargeException
void setMaxRequestLength(long maxRequestLength)
Request
.
This value is initially set from ServerConfig.defaultMaxRequestLength()
.
If 0, there is no limit on the request size.ContentTooLargeException
© Copyright 2015–2018 LINE Corporation. All rights reserved.