public final class ServerRequestContext extends Object
HttpRequest that is bound to instrumented threads.
Allowing lookup of the current request if it is present.| Modifier and Type | Method and Description |
|---|---|
static <T> Optional<HttpRequest<T>> |
currentRequest()
Retrieve the current server request context.
|
static Runnable |
instrument(HttpRequest request,
Runnable runnable)
Return a new runnable by instrumenting the given runnable with request context handling.
|
static void |
set(HttpRequest request)
Set
HttpRequest. |
static <T> T |
with(HttpRequest request,
Callable<T> callable)
Wrap the execution of the given callable in request context processing.
|
static void |
with(HttpRequest request,
Runnable runnable)
Wrap the execution of the given runnable in request context processing.
|
static <T> T |
with(HttpRequest request,
Supplier<T> callable)
Wrap the execution of the given callable in request context processing.
|
public static final String KEY
public static void set(@Nullable HttpRequest request)
HttpRequest.request - new HttpRequestpublic static void with(@Nullable HttpRequest request, @NonNull Runnable runnable)
request - The requestrunnable - The runnablepublic static Runnable instrument(@Nullable HttpRequest request, @NonNull Runnable runnable)
request - The requestrunnable - The runnablepublic static <T> T with(@Nullable HttpRequest request, @NonNull Supplier<T> callable)
T - The return type of the callablerequest - The requestcallable - The callablepublic static <T> T with(@Nullable HttpRequest request, @NonNull Callable<T> callable) throws Exception
T - The return type of the callablerequest - The requestcallable - The callableException - If the callable throws an exceptionpublic static <T> Optional<HttpRequest<T>> currentRequest()
T - The body type