public class ServiceRequestContextWrapper extends RequestContextWrapper<ServiceRequestContext> implements ServiceRequestContext
ServiceRequestContext.| Modifier | Constructor and Description |
|---|---|
protected |
ServiceRequestContextWrapper(ServiceRequestContext delegate)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
AccessLogWriter |
accessLogWriter() |
void |
addAdditionalResponseHeader(CharSequence name,
Object value)
Adds a header with the specified
name and value. |
void |
addAdditionalResponseHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
|
void |
addAdditionalResponseTrailer(CharSequence name,
Object value)
Adds a trailer with the specified
name and value. |
void |
addAdditionalResponseTrailers(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
|
HttpHeaders |
additionalResponseHeaders()
|
HttpHeaders |
additionalResponseTrailers()
Returns the
HttpHeaders which is returned along with any other trailers when a
Service completes an HttpResponse. |
ScheduledExecutorService |
blockingTaskExecutor()
Returns the
ScheduledExecutorService that could be used for executing a potentially
long-running task. |
InetAddress |
clientAddress()
Returns the address of the client who initiated this request.
|
String |
decodedMappedPath()
Returns the
RequestContext.decodedPath() with its context path removed. |
<A extends SocketAddress> |
localAddress()
Returns the local address of this request, or
null if the connection is not established yet. |
org.slf4j.Logger |
logger()
Returns the
Logger of the Service. |
String |
mappedPath()
Returns the
RequestContext.path() with its context path removed. |
long |
maxRequestLength()
Returns the maximum length of the current
Request. |
MediaType |
negotiatedResponseMediaType()
Returns the negotiated producible media type.
|
ServiceRequestContext |
newDerivedContext(RequestId id,
HttpRequest req,
RpcRequest rpcReq)
Creates a new
RequestContext whose properties and Attributes are copied from this
RequestContext, except having a different pair of HttpRequest and RpcRequest
and its own RequestLog. |
Map<String,String> |
pathParams()
Returns the path parameters mapped by the
ServiceRequestContext.route() associated with the Service
that is handling the current Request. |
ProxiedAddresses |
proxiedAddresses()
Returns the proxied addresses of the current
Request. |
<A extends SocketAddress> |
remoteAddress()
Returns the remote address of this request, or
null if the connection is not established yet. |
boolean |
removeAdditionalResponseHeader(CharSequence name)
Removes all headers with the specified
name. |
boolean |
removeAdditionalResponseTrailer(CharSequence name)
Removes all trailers with the specified
name. |
HttpRequest |
request()
Returns the
HttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet. |
Runnable |
requestTimeoutHandler()
Returns
Request timeout handler which is executed when
receiving the current Request and sending the corresponding Response
is not completely received within the allowed ServiceRequestContext.requestTimeoutMillis(). |
long |
requestTimeoutMillis()
|
Route |
route()
|
RoutingContext |
routingContext()
Returns the
RoutingContext used to find the Service. |
Server |
server()
|
HttpService |
service()
Returns the
HttpService that is handling the current Request. |
void |
setAdditionalResponseHeader(CharSequence name,
Object value)
Sets a header with the specified
name and value. |
void |
setAdditionalResponseHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Clears the current header and sets the specified
HttpHeaders which is included when a
Service sends an HttpResponse. |
void |
setAdditionalResponseTrailer(CharSequence name,
Object value)
Sets a trailer with the specified
name and value. |
void |
setAdditionalResponseTrailers(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Clears the current trailer and sets the specified
HttpHeaders which is included when a
Service completes an HttpResponse. |
void |
setMaxRequestLength(long maxRequestLength)
Sets the maximum length of the current
Request. |
void |
setRequestTimeout(Duration requestTimeout)
|
void |
setRequestTimeoutHandler(Runnable requestTimeoutHandler)
Sets a handler to run when the request times out.
|
void |
setRequestTimeoutMillis(long requestTimeoutMillis)
|
boolean |
verboseResponses()
Returns whether the verbose response mode is enabled.
|
VirtualHost |
virtualHost()
Returns the
VirtualHost that is handling the current Request. |
alloc, attr, attrs, decodedPath, delegate, eventLoop, hasAttr, id, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, log, logBuilder, meterRegistry, method, onChild, onEnter, onExit, path, query, rpcRequest, sessionProtocol, sslSession, updateRequest, updateRpcRequestcontextAwareEventLoop, contextAwareExecutor, equals, executor, hashCode, isTimedOut, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, onEnter, onExit, push, push, pushIfAbsent, rejectPromise, resolvePromise, setTimedOutclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitbuilder, current, currentOrNull, isTimedOut, mapCurrent, negotiatedProduceType, of, pathParam, rpcRequestalloc, attrs, contextAwareEventLoop, contextAwareExecutor, decodedPath, eventLoop, executor, id, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, log, logBuilder, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, mapCurrent, meterRegistry, method, onChild, onEnter, onEnter, onExit, onExit, path, push, push, push, push, pushIfAbsent, query, rejectPromise, resolvePromise, sessionProtocol, sslSession, updateRequest, updateRpcRequestprotected ServiceRequestContextWrapper(ServiceRequestContext delegate)
@Nonnull public HttpRequest request()
RequestContextHttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet.request in interface RequestContextrequest in interface ServiceRequestContextrequest in class RequestContextWrapper<ServiceRequestContext>@Nonnull public <A extends SocketAddress> A remoteAddress()
RequestContextnull if the connection is not established yet.remoteAddress in interface RequestContextremoteAddress in interface ServiceRequestContextremoteAddress in class RequestContextWrapper<ServiceRequestContext>@Nonnull public <A extends SocketAddress> A localAddress()
RequestContextnull if the connection is not established yet.localAddress in interface RequestContextlocalAddress in interface ServiceRequestContextlocalAddress in class RequestContextWrapper<ServiceRequestContext>public InetAddress clientAddress()
ServiceRequestContextclientAddress in interface ServiceRequestContextpublic ServiceRequestContext newDerivedContext(RequestId id, @Nullable HttpRequest req, @Nullable RpcRequest rpcReq)
RequestContextRequestContext whose properties and Attributes are copied from this
RequestContext, except having a different pair of HttpRequest and RpcRequest
and its own RequestLog.newDerivedContext in interface RequestContextnewDerivedContext in interface ServiceRequestContextpublic Server server()
ServiceRequestContextserver in interface ServiceRequestContextpublic VirtualHost virtualHost()
ServiceRequestContextVirtualHost that is handling the current Request.virtualHost in interface ServiceRequestContextpublic Route route()
ServiceRequestContextroute in interface ServiceRequestContextpublic RoutingContext routingContext()
ServiceRequestContextRoutingContext used to find the Service.routingContext in interface ServiceRequestContextpublic Map<String,String> pathParams()
ServiceRequestContextServiceRequestContext.route() associated with the Service
that is handling the current Request.pathParams in interface ServiceRequestContextpublic HttpService service()
ServiceRequestContextHttpService that is handling the current Request.service in interface ServiceRequestContextpublic ScheduledExecutorService blockingTaskExecutor()
ServiceRequestContextScheduledExecutorService that could be used for executing a potentially
long-running task. The ScheduledExecutorService 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.
blockingTaskExecutor in interface ServiceRequestContextpublic String mappedPath()
ServiceRequestContextRequestContext.path() with its context path removed. This method can be useful for a reusable
service bound at various path prefixes.mappedPath in interface ServiceRequestContextpublic String decodedMappedPath()
ServiceRequestContextRequestContext.decodedPath() with its context path removed. This method can be useful for
a reusable service bound at various path prefixes.decodedMappedPath in interface ServiceRequestContext@Nullable public MediaType negotiatedResponseMediaType()
ServiceRequestContextService, null would be returned.negotiatedResponseMediaType in interface ServiceRequestContextpublic org.slf4j.Logger logger()
ServiceRequestContextLogger of the Service.logger in interface ServiceRequestContextpublic long requestTimeoutMillis()
ServiceRequestContextRequest and sending
the corresponding Response completely.
This value is initially set from ServiceConfig.requestTimeoutMillis().requestTimeoutMillis in interface ServiceRequestContextpublic void setRequestTimeoutMillis(long requestTimeoutMillis)
ServiceRequestContextRequest and sending
the corresponding Response completely.
This value is initially set from ServiceConfig.requestTimeoutMillis().setRequestTimeoutMillis in interface ServiceRequestContextpublic void setRequestTimeout(Duration requestTimeout)
ServiceRequestContextRequest and sending
the corresponding Response completely.
This value is initially set from ServiceConfig.requestTimeoutMillis().setRequestTimeout in interface ServiceRequestContext@Nullable public Runnable requestTimeoutHandler()
ServiceRequestContextRequest timeout handler which is executed when
receiving the current Request and sending the corresponding Response
is not completely received within the allowed ServiceRequestContext.requestTimeoutMillis().requestTimeoutHandler in interface ServiceRequestContextpublic void setRequestTimeoutHandler(Runnable requestTimeoutHandler)
ServiceRequestContextrequestTimeoutHandler 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(ResponseHeaders.of(HttpStatus.OK,
HttpHeaderNames.CONTENT_TYPE, MediaType.PLAIN_TEXT_UTF_8));
res.write(HttpData.ofUtf8("Request timed out."));
res.close();
});
...
setRequestTimeoutHandler in interface ServiceRequestContextpublic long maxRequestLength()
ServiceRequestContextRequest.
This value is initially set from ServiceConfig.maxRequestLength().
If 0, there is no limit on the request size.maxRequestLength in interface ServiceRequestContextContentTooLargeExceptionpublic void setMaxRequestLength(long maxRequestLength)
ServiceRequestContextRequest.
This value is initially set from ServiceConfig.maxRequestLength().
If 0, there is no limit on the request size.setMaxRequestLength in interface ServiceRequestContextContentTooLargeExceptionpublic boolean verboseResponses()
ServiceRequestContextverboseResponses in interface ServiceRequestContextpublic AccessLogWriter accessLogWriter()
accessLogWriter in interface ServiceRequestContextpublic HttpHeaders additionalResponseHeaders()
ServiceRequestContextadditionalResponseHeaders in interface ServiceRequestContextpublic void setAdditionalResponseHeader(CharSequence name, Object value)
ServiceRequestContextname and value. This will remove all previous values
associated with the specified name.
The header will be included when a Service sends an HttpResponse.setAdditionalResponseHeader in interface ServiceRequestContextpublic void setAdditionalResponseHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ServiceRequestContextHttpHeaders which is included when a
Service sends an HttpResponse.setAdditionalResponseHeaders in interface ServiceRequestContextpublic void addAdditionalResponseHeader(CharSequence name, Object value)
ServiceRequestContextname and value. The header will be included when
a Service sends an HttpResponse.addAdditionalResponseHeader in interface ServiceRequestContextpublic void addAdditionalResponseHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ServiceRequestContextaddAdditionalResponseHeaders in interface ServiceRequestContextpublic boolean removeAdditionalResponseHeader(CharSequence name)
ServiceRequestContextname.removeAdditionalResponseHeader in interface ServiceRequestContexttrue if at least one entry has been removedpublic HttpHeaders additionalResponseTrailers()
ServiceRequestContextHttpHeaders which is returned along with any other trailers when a
Service completes an HttpResponse.additionalResponseTrailers in interface ServiceRequestContextpublic void setAdditionalResponseTrailer(CharSequence name, Object value)
ServiceRequestContextname and value. This will remove all previous values
associated with the specified name.
The trailer will be included when a Service completes an HttpResponse.setAdditionalResponseTrailer in interface ServiceRequestContextpublic void setAdditionalResponseTrailers(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ServiceRequestContextHttpHeaders which is included when a
Service completes an HttpResponse.setAdditionalResponseTrailers in interface ServiceRequestContextpublic void addAdditionalResponseTrailer(CharSequence name, Object value)
ServiceRequestContextname and value. The trailer will be included when
a Service completes an HttpResponse.addAdditionalResponseTrailer in interface ServiceRequestContextpublic void addAdditionalResponseTrailers(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ServiceRequestContextaddAdditionalResponseTrailers in interface ServiceRequestContextpublic boolean removeAdditionalResponseTrailer(CharSequence name)
ServiceRequestContextname.removeAdditionalResponseTrailer in interface ServiceRequestContexttrue if at least one entry has been removedpublic ProxiedAddresses proxiedAddresses()
ServiceRequestContextRequest.proxiedAddresses in interface ServiceRequestContextCopyright © 2020 LeanCloud. All rights reserved.