RouteData class

Constructors

RouteData({required String method, required String path, required dynamic controllers, bool? corsEnabled, List preMiddleware = const <dynamic>[], String? domain, Object? body})

Properties

action → Function?
The function that handles the request, read once: the last function of controllers, or the controller method that a ControllerAction (Route.get<C>(path, (C c) => c.index)) or a (C c) => c.index function picks. The controller comes from the container. Null when the route has no controller function.
no setter
body ↔ Object?
request body schema for the OpenAPI docs, from the body: option. any object with toJsonSchema(), like a dox_validation schema.
getter/setter pair
controllers → dynamic
final
corsEnabled → bool?
final
domain → String?
final
domainLower → String?
domain in lower case, made once.
latefinal
errorRenderer ↔ RouteErrorRenderer?
renders the errors of this route, see Route.renderErrorsWith
getter/setter pair
fallbackWhen ↔ FallbackCondition?
for a Route.fallback with when: runs for any method when it gives true. null: GET and HEAD only.
getter/setter pair
handler → ControllerPlan?
How to call the controller (the last function of controllers), read once. Null when the route has no controller function. Throws a StateError when a parameter type is not known.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasSegments → bool
true when the route has params and every part between slashes is plain text or one whole required param, like /users/{id}/posts. Then matchSegments gives the same answer as pattern, with no regex. False for {id?}, {path*}, Route.where, a part like v{id}, and text with regex marks in it (eg. a.b).
no setter
isWebSocket ↔ bool
true for a route added with Route.websocket
getter/setter pair
matchPrefix → String?
The plain text before the first param, eg. /api/users for /api/users/{id}. A url that does not start with it can not match pattern, so the router skips the regex. Null for a plain route, a route that starts with a param, or text with regex marks in it.
no setter
method → String
final
name ↔ String?
set by Route.get(...).name('users.show'), see Route.url
getter/setter pair
paramNames → List<String>
names of the params, eg. ['id'] for /blog/{id}. A part can mix text and params: /v{id} and /{a}-{b}. {path*} matches the rest of the url, slashes too. {id?} is optional: /blog and /blog/5 both match.
no setter
path ↔ String
getter/setter pair
pattern → RegExp?
regex for a route with params like /blog/{id}, built once. null for a plain route, which is matched with ==.
no setter
preMiddleware ↔ List
middleware from groups and routers (Route.middleware, global middleware). they are also the first items of controllers.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
terminable → List<IDoxTerminableMiddleware>
The middleware of this route with a terminate step (IDoxTerminableMiddleware), in order. Read once. Empty for most routes.
no setter
usesNext → bool
True when a middleware of this route takes a next (IDoxNextMiddleware or a NextMiddlewareFunction). Read once.
no setter
wheres ↔ Map<String, String>?
param name => regex, set with Route.where. null for most routes, so they build the same pattern as before.
getter/setter pair

Methods

matchSegments(String path) → List<String>?
The param values when path matches this route, in the order of paramNames. Null when it does not match. Only for a route with hasSegments: for other routes it gives null.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
where(String param, String regex) → void
only match param when its text matches regex, see Route.where. A leading ^ and a trailing $ are dropped: the regex must match the whole param text anyway, and inside the route regex they would never match.
whereCheck(String param) → RegExp?
The Route.where regex of param as a full match (^(?:regex)$), built once. Null when param has no where. The router checks the param with it again after % decoding, so %2F can not sneak a / past a rule like [^/]+.

Operators

operator ==(Object other) → bool
The equality operator.
inherited