router/route library

Classes

ControllerAction<T extends Object>
A route action that points to a method of a controller from the container. The controller is made once per isolate, at start.
Route
RouteBinding
one binder added with Route.bind

Functions

isWebSocketUpgrade(HttpRequest req) → bool
true when req asks for a WebSocket upgrade, on either server
route(String name, {Map<String, Object?> params = const <String, Object?>{}, Map<String, Object?> query = const <String, Object?>{}, bool absolute = false, String? baseUrl}) → String
the path of the route named name, see Route.url.
upgradeWebSocket(HttpRequest req, {String? protocol, int maxMessageSize = 16 * 1024 * 1024}) → Future<WebSocket>
Accepts the WebSocket upgrade of req on the server Dox runs on (dox_http_native, or the server of startServer(server:)). For the raw handler of a Route.mount (like Socket.IO): Route.websocket does this itself. protocol is the subprotocol to answer with. A message or frame over maxMessageSize bytes closes the socket with 1009.
webSocketOriginAllowed(String? origin, String? host, List<String> allowedOrigins) → bool
true when a WebSocket upgrade with this origin may open.

Typedefs

FallbackCondition = bool Function(HttpRequest req)
true when a Route.fallback with when should answer req
RawRequestHandler = Future<void> Function(HttpRequest request)
raw handler for every request under a path prefix, see Route.mount
RouteBinder<T> = FutureOr<T?> Function(String value)
turns the raw text of a route param into a value, like a model. null means not found: the request gets 404.
RouteErrorRenderer = DoxResponse? Function(Object error, DoxRequest req)
Gives the response for an error of a route, see Route.renderErrorsWith. null: Dox renders it as usual.
WebSocketHandler = FutureOr<void> Function(WebSocket socket, DoxRequest req)
gets the open socket of a Route.websocket request