Class RequestLifecycle

java.lang.Object
io.micronaut.http.server.RequestLifecycle

@Internal public class RequestLifecycle extends Object
This class handles the full route processing lifecycle for a request.
Since:
4.0.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    RequestLifecycle(RouteExecutor routeExecutor, io.micronaut.http.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 Type
    Method
    Description
    protected @Nullable FileCustomizableResponseType
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will be removed after 4.3.0
    protected @Nullable FileCustomizableResponseType
    findFile(io.micronaut.http.HttpRequest<?> request)
    Try to find a static file for this request.
    protected io.micronaut.core.execution.ExecutionFlow<io.micronaut.web.router.RouteMatch<?>>
    fulfillArguments(io.micronaut.web.router.RouteMatch<?> routeMatch, io.micronaut.http.HttpRequest<?> request)
    Fulfill the arguments of the given route with data from the request.
    protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will be removed after 4.3.0
    protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>
    normalFlow(io.micronaut.http.HttpRequest<?> request)
    Execute this request normally.
    protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>
    onError(io.micronaut.http.HttpRequest<?> request, Throwable throwable)
    Handle an error in this request.
    protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>
    onStatusError(io.micronaut.http.HttpRequest<?> request, io.micronaut.http.MutableHttpResponse<?> defaultResponse, String message)
    Build a status response.
    protected final io.micronaut.http.HttpRequest<?>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Will be removed after 4.3.0
    protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>
    runWithFilters(io.micronaut.http.HttpRequest<?> request, BiFunction<io.micronaut.http.HttpRequest<?>,io.micronaut.core.propagation.PropagatedContext,io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>> responseProvider)
    Run the filters for this request, and then run the given flow.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RequestLifecycle

      protected RequestLifecycle(RouteExecutor routeExecutor)
      Parameters:
      routeExecutor - The route executor to use for route resolution
    • RequestLifecycle

      @Deprecated(forRemoval=true, since="4.3.0") protected RequestLifecycle(RouteExecutor routeExecutor, io.micronaut.http.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 resolution
      request - The request
  • Method Details

    • normalFlow

      @Deprecated(forRemoval=true, since="4.3.0") protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> normalFlow()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will be removed after 4.3.0
      Execute this request normally.
      Returns:
      The response to the request.
    • request

      @Deprecated(forRemoval=true, since="4.3.0") protected final io.micronaut.http.HttpRequest<?> request()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will be removed after 4.3.0
      The request for this lifecycle. This may be changed by filters.
      Returns:
      The current request
    • findFile

      @Deprecated(forRemoval=true, since="4.3.0") @Nullable protected @Nullable FileCustomizableResponseType findFile()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Will be removed after 4.3.0
      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.
      Returns:
      The file at this path, or null if none is found
    • normalFlow

      protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> normalFlow(io.micronaut.http.HttpRequest<?> request)
      Execute this request normally.
      Parameters:
      request - The request
      Returns:
      The response to the request.
    • onError

      protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> onError(io.micronaut.http.HttpRequest<?> request, Throwable throwable)
      Handle an error in this request. It also runs filters for the error handling.
      Parameters:
      request - The request
      throwable - The error
      Returns:
      The response for the error
    • runWithFilters

      protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> runWithFilters(io.micronaut.http.HttpRequest<?> request, BiFunction<io.micronaut.http.HttpRequest<?>,io.micronaut.core.propagation.PropagatedContext,io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>>> responseProvider)
      Run the filters for this request, and then run the given flow.
      Parameters:
      request - The request
      responseProvider - Downstream flow, runs inside the filters
      Returns:
      Execution flow that completes after the all the filters and the downstream flow
    • onStatusError

      protected final io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> onStatusError(io.micronaut.http.HttpRequest<?> request, io.micronaut.http.MutableHttpResponse<?> defaultResponse, String message)
      Build a status response. Calls any status routes, if available.
      Parameters:
      request - The request
      defaultResponse - The default response if there is no status route
      message - The error message
      Returns:
      The computed response flow
    • findFile

      @Nullable protected @Nullable FileCustomizableResponseType findFile(io.micronaut.http.HttpRequest<?> request)
      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 null if none is found
    • fulfillArguments

      protected io.micronaut.core.execution.ExecutionFlow<io.micronaut.web.router.RouteMatch<?>> fulfillArguments(io.micronaut.web.router.RouteMatch<?> routeMatch, io.micronaut.http.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 are Optional. They are satisfied with Optional.empty() later.
      Parameters:
      routeMatch - The route match to fulfill
      request - The request
      Returns:
      The fulfilled route match, after all necessary data is available