Class BasicHttpAttributes

java.lang.Object
io.micronaut.http.BasicHttpAttributes

public final class BasicHttpAttributes extends Object
Accessors for basic attributes outside micronaut-http-router.
Since:
4.8.0
Author:
Jonas Konrad
  • Method Details

    • getRouteMatchInfo

      public static Optional<UriMatchInfo> getRouteMatchInfo(HttpRequest<?> request)
      Get the route match as a UriMatchInfo.
      Parameters:
      request - The request
      Returns:
      The route match, if present
    • getUriTemplate

      public static Optional<String> getUriTemplate(HttpRequest<?> request)
      Get the URI template as a String, for tracing.
      Parameters:
      request - The request
      Returns:
      The template, if present
    • setUriTemplate

      public static void setUriTemplate(HttpRequest<?> request, String uriTemplate)
      Set the URI template as a String, for tracing.
      Parameters:
      request - The request
      uriTemplate - The template, if present
    • getServiceId

      public static Optional<String> getServiceId(HttpRequest<?> request)
      Get the client service ID.
      Parameters:
      request - The request
      Returns:
      The client service ID
    • getRouteWaitsFor

      public static ExecutionFlow<?> getRouteWaitsFor(HttpRequest<?> request)
      A condition that must be awaited before executing controllers for the given request. This is used to delay execution for argument binding.
      Parameters:
      request - The request
      Returns:
      The condition to wait for
    • takeRouteWaitsFor

      @Internal public static ExecutionFlow<?> takeRouteWaitsFor(HttpRequest<?> request)
      Remove the conditions that must be awaited before executing controllers for the given request and return them.
      Parameters:
      request - The request
      Returns:
      The condition to wait for
      Since:
      5.2.21
    • addRouteWaitsFor

      public static void addRouteWaitsFor(HttpRequest<?> request, ExecutionFlow<?> flowToAdd)
      Add a condition that must be awaited before executing controllers for the given request. This is used to delay execution for argument binding.
      Parameters:
      request - The request
      flowToAdd - The condition to wait for
    • addUnconsumedBodyDiscard

      @Internal public static void addUnconsumedBodyDiscard(HttpRequest<?> request, Runnable discard)
      Register an action that discards a streaming body argument the route does not consume. Argument binders that claim the request body before the route executes (e.g. for a Publisher or InputStream argument) use this so that the body is not left buffered, and the connection stalled, when the request is rejected, e.g. because another argument fails to bind or a @Valid constraint is violated, or when the route returns without ever subscribing to the argument. The action must leave a body alone that the route has started to consume.
      Parameters:
      request - The request
      discard - The action that discards the body
    • addUnconsumedBodyDiscard

      @Internal public static void addUnconsumedBodyDiscard(HttpRequest<?> request, Runnable onRouteFailure, Runnable afterResponse)
      Register the actions that discard a streaming body argument the route does not consume.
      Parameters:
      request - The request
      onRouteFailure - The action that discards the body if the route fails before it returns
      afterResponse - The action that discards the body once the response has been written, if the route never started to consume it
    • discardUnconsumedBodies

      @Internal public static void discardUnconsumedBodies(HttpRequest<?> request)
      Run the actions registered with addUnconsumedBodyDiscard(HttpRequest, Runnable). This is called when the route is not invoked, or its invocation throws, for a request whose arguments were (partially) bound. Each registration runs at most once.
      Parameters:
      request - The request
    • discardUnsubscribedBodies

      @Internal public static void discardUnsubscribedBodies(HttpRequest<?> request)
      Discard the streaming body arguments the route never started to consume. This is called once the response has been written. Each registration runs at most once.
      Parameters:
      request - The request