Class RequestLifecycle

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

public class RequestLifecycle extends Object
This class handles the full route processing lifecycle for a request.
Since:
4.0.0
Author:
Jonas Konrad
  • Constructor Details

    • RequestLifecycle

      protected RequestLifecycle(RouteExecutor routeExecutor, HttpRequest<?> request)
      Parameters:
      routeExecutor - The route executor to use for route resolution
      request - The request to process
  • Method Details

    • request

      protected final HttpRequest<?> request()
      The request for this lifecycle. This may be changed by filters.
      Returns:
      The current request
    • multipartEnabled

      protected final void multipartEnabled(boolean multipartEnabled)
    • normalFlow

      protected final ExecutionFlow<MutableHttpResponse<?>> normalFlow()
      Execute this request normally.
      Returns:
      The response to the request.
    • onError

      protected final ExecutionFlow<MutableHttpResponse<?>> onError(Throwable t)
      Handle an error in this request. Also runs filters for the error handling.
      Parameters:
      t - The error
      Returns:
      The response for the error
    • runWithFilters

      protected final ExecutionFlow<MutableHttpResponse<?>> runWithFilters(Supplier<ExecutionFlow<MutableHttpResponse<?>>> downstream)
      Run the filters for this request, and then run the given flow.
      Parameters:
      downstream - Downstream flow, runs inside the filters
      Returns:
      Execution flow that completes after the all the filters and the downstream flow
    • onStatusError

      protected final ExecutionFlow<MutableHttpResponse<?>> onStatusError(MutableHttpResponse<?> defaultResponse, String message)
      Build a status response. Calls any status routes, if available.
      Parameters:
      defaultResponse - The default response if there is no status route
      message - The error message
      Returns:
      The computed response flow
    • 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.
      Returns:
      The file at this path, or null if none is found
    • fulfillArguments

      protected ExecutionFlow<RouteMatch<?>> fulfillArguments(RouteMatch<?> routeMatch)
      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
      Returns:
      The fulfilled route match, after all necessary data is available