Class WebSocketUpgradeRequestLifecycle
java.lang.Object
io.micronaut.http.server.RequestLifecycle
io.micronaut.servlet.http.websocket.WebSocketUpgradeRequestLifecycle
@Internal
public final class WebSocketUpgradeRequestLifecycle
extends io.micronaut.http.server.RequestLifecycle
Runs the Micronaut server filter chain against a WebSocket upgrade request so that
filters and security see the handshake before the connection is switched over to the
WebSocket protocol.
This mirrors the behaviour of the Netty server: the filter chain is invoked with a
sentinel response, and the upgrade only proceeds when that exact response instance
survives the chain. A filter that produces its own response (a 401 from
micronaut-security, for example) therefore cancels the upgrade and its response is
written as an ordinary HTTP response.
- Since:
- 6.2.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketUpgradeRequestLifecycle(io.micronaut.http.server.RouteExecutor routeExecutor, io.micronaut.web.router.Router router) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> handle(io.micronaut.http.HttpRequest<?> request) Match the request to a WebSocket route and run the filter chain against it.booleanMethods inherited from class io.micronaut.http.server.RequestLifecycle
findFile, findFile, fulfillArguments, normalFlow, normalFlow, onError, onStatusError, request, runWithFilters
-
Constructor Details
-
WebSocketUpgradeRequestLifecycle
public WebSocketUpgradeRequestLifecycle(io.micronaut.http.server.RouteExecutor routeExecutor, io.micronaut.web.router.Router router) Default constructor.- Parameters:
routeExecutor- The route executorrouter- The router used to look up the WebSocket route
-
-
Method Details
-
handle
public io.micronaut.core.execution.ExecutionFlow<io.micronaut.http.HttpResponse<?>> handle(io.micronaut.http.HttpRequest<?> request) Match the request to a WebSocket route and run the filter chain against it.- Parameters:
request- The upgrade request- Returns:
- A flow producing either the sentinel response, meaning the upgrade may proceed, or the response a filter substituted for it
-
shouldProceedNormally
public boolean shouldProceedNormally()- Returns:
- Whether the upgrade should proceed, meaning no filter substituted a response
-
getRouteMatch
-