Class RequestLifecycle
java.lang.Object
io.micronaut.http.server.RequestLifecycle
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRequestLifecycle(RouteExecutor routeExecutor) protectedRequestLifecycle(RouteExecutor routeExecutor, HttpRequest<?> request) Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0 -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable FileCustomizableResponseTypefindFile()Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0protected @Nullable FileCustomizableResponseTypefindFile(HttpRequest<?> request) Try to find a static file for this request.protected ExecutionFlow<RouteMatch<?>> fulfillArguments(RouteMatch<?> routeMatch, HttpRequest<?> request) Fulfill the arguments of the given route with data from the request.protected final ExecutionFlow<HttpResponse<?>> Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0protected final ExecutionFlow<HttpResponse<?>> normalFlow(@Nullable HttpRequest<?> request) Execute this request normally.protected final ExecutionFlow<HttpResponse<?>> onError(HttpRequest<?> request, Throwable throwable) Handle an error in this request.protected final ExecutionFlow<HttpResponse<?>> onStatusError(HttpRequest<?> request, MutableHttpResponse<?> defaultResponse, String message) protected final @Nullable HttpRequest<?> request()Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0protected voidrequestContextResolved(HttpRequest<?> request, PropagatedContext propagatedContext) Called with the propagated context of the request once the request filters ran, e.g.protected final ExecutionFlow<HttpResponse<?>> runWithFilters(HttpRequest<?> request, BiFunction<HttpRequest<?>, PropagatedContext, ExecutionFlow<HttpResponse<?>>> responseProvider) Run the filters for this request, and then run the given flow.protected final ExecutionFlow<HttpResponse<?>> runWithPreMatchingFilters(HttpRequest<?> request, Consumer<HttpRequest<?>> routeMatcher, BiFunction<HttpRequest<?>, PropagatedContext, ExecutionFlow<HttpResponse<?>>> responseProvider) Run the pre-matching filters and the filters for this request, and then run the given flow.
-
Constructor Details
-
RequestLifecycle
- Parameters:
routeExecutor- The route executor to use for route resolution
-
RequestLifecycle
@Deprecated(forRemoval=true, since="4.3.0") protected RequestLifecycle(RouteExecutor routeExecutor, HttpRequest<?> request) Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0- Parameters:
routeExecutor- The route executor to use for route resolutionrequest- The request
-
-
Method Details
-
normalFlow
@Deprecated(forRemoval=true, since="4.3.0") protected final ExecutionFlow<HttpResponse<?>> normalFlow()Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0Execute this request normally.- Returns:
- The response to the request.
-
request
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0The request for this lifecycle. This may be changed by filters.- Returns:
- The current request
-
findFile
@Deprecated(forRemoval=true, since="4.3.0") protected @Nullable FileCustomizableResponseType findFile()Deprecated, for removal: This API element is subject to removal in a future version.Will be removed after 4.3.0Try to find a static file for this request. If there is a file, filters will still run, but only after the call to this method.- Returns:
- The file at this path, or
nullif none is found
-
normalFlow
Execute this request normally.- Parameters:
request- The request- Returns:
- The response to the request.
-
onError
Handle an error in this request. It also runs filters for the error handling.- Parameters:
request- The requestthrowable- The error- Returns:
- The response for the error
-
runWithFilters
protected final ExecutionFlow<HttpResponse<?>> runWithFilters(HttpRequest<?> request, BiFunction<HttpRequest<?>, PropagatedContext, ExecutionFlow<HttpResponse<?>>> responseProvider) Run the filters for this request, and then run the given flow.- Parameters:
request- The requestresponseProvider- Downstream flow, runs inside the filters- Returns:
- Execution flow that completes after the all the filters and the downstream flow
-
runWithPreMatchingFilters
protected final ExecutionFlow<HttpResponse<?>> runWithPreMatchingFilters(HttpRequest<?> request, Consumer<HttpRequest<?>> routeMatcher, BiFunction<HttpRequest<?>, PropagatedContext, ExecutionFlow<HttpResponse<?>>> responseProvider) Run the pre-matching filters and the filters for this request, and then run the given flow. The route matcher runs after the pre-matching filters, which can change the request, and must set the matched route on the request.- Parameters:
request- The requestrouteMatcher- Matches the route of the request returned by the pre-matching filtersresponseProvider- Downstream flow, runs inside the filters- Returns:
- Execution flow that completes after the all the filters and the downstream flow
- Since:
- 5.2.21
-
requestContextResolved
Called with the propagated context of the request once the request filters ran, e.g. with the MDC or the trace they added.- Parameters:
request- The requestpropagatedContext- The context- Since:
- 5.2.21
-
onStatusError
protected final ExecutionFlow<HttpResponse<?>> onStatusError(HttpRequest<?> request, MutableHttpResponse<?> defaultResponse, String message) -
findFile
Try to find a static file for this request. If there is a file, filters will still run, but only after the call to this method.- Parameters:
request- The request- Returns:
- The file at this path, or
nullif none is found
-
fulfillArguments
protected ExecutionFlow<RouteMatch<?>> fulfillArguments(RouteMatch<?> routeMatch, HttpRequest<?> request) Fulfill the arguments of the given route with data from the request. If necessary, this also waits for body data to be available, if there are arguments that need immediate binding.
Note that in some cases some arguments may still be unsatisfied after this, if they are missing and areOptional. They are satisfied withOptional.empty()later.- Parameters:
routeMatch- The route match to fulfillrequest- The request- Returns:
- The fulfilled route match, after all necessary data is available
-