Class BasicHttpAttributes
java.lang.Object
io.micronaut.http.BasicHttpAttributes
Accessors for basic attributes outside micronaut-http-router.
- Since:
- 4.8.0
- Author:
- Jonas Konrad
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddRouteWaitsFor(HttpRequest<?> request, ExecutionFlow<?> flowToAdd) Add a condition that must be awaited before executing controllers for the given request.static voidaddUnconsumedBodyDiscard(HttpRequest<?> request, Runnable discard) Register an action that discards a streaming body argument the route does not consume.static voidaddUnconsumedBodyDiscard(HttpRequest<?> request, Runnable onRouteFailure, Runnable afterResponse) Register the actions that discard a streaming body argument the route does not consume.static voiddiscardUnconsumedBodies(HttpRequest<?> request) Run the actions registered withaddUnconsumedBodyDiscard(HttpRequest, Runnable).static voiddiscardUnsubscribedBodies(HttpRequest<?> request) Discard the streaming body arguments the route never started to consume.static Optional<UriMatchInfo> getRouteMatchInfo(HttpRequest<?> request) Get the route match as aUriMatchInfo.static ExecutionFlow<?> getRouteWaitsFor(HttpRequest<?> request) A condition that must be awaited before executing controllers for the given request.getServiceId(HttpRequest<?> request) Get the client service ID.getUriTemplate(HttpRequest<?> request) Get the URI template as a String, for tracing.static voidsetUriTemplate(HttpRequest<?> request, String uriTemplate) Set the URI template as a String, for tracing.static ExecutionFlow<?> takeRouteWaitsFor(HttpRequest<?> request) Remove the conditions that must be awaited before executing controllers for the given request and return them.
-
Method Details
-
getRouteMatchInfo
Get the route match as aUriMatchInfo.- Parameters:
request- The request- Returns:
- The route match, if present
-
getUriTemplate
Get the URI template as a String, for tracing.- Parameters:
request- The request- Returns:
- The template, if present
-
setUriTemplate
Set the URI template as a String, for tracing.- Parameters:
request- The requesturiTemplate- The template, if present
-
getServiceId
Get the client service ID.- Parameters:
request- The request- Returns:
- The client service ID
-
getRouteWaitsFor
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
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
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 requestflowToAdd- The condition to wait for
-
addUnconsumedBodyDiscard
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 aPublisherorInputStreamargument) 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@Validconstraint 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 requestdiscard- 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 requestonRouteFailure- The action that discards the body if the route fails before it returnsafterResponse- The action that discards the body once the response has been written, if the route never started to consume it
-
discardUnconsumedBodies
Run the actions registered withaddUnconsumedBodyDiscard(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
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
-