Router<T extends Object> class
final
A URL router that maps path patterns to values of type T.
Supports static paths (e.g., /users/profile) and paths with named parameters
(e.g., /users/:id). Normalizes paths before matching.
- Available extensions
Constructors
- Router()
Properties
- asHandler → Handler
-
Available on RelicRouter, provided by the RouterHandlerEx extension
Makes RelicRouter callable as a Handler.no setter - fallback ↔ T?
-
The fallback value returned when no route matches the request path.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns true if the router has no routes.
no setter
- isSingle → bool
-
Returns true if the router has a single root route ('/').
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
Method method, String path, T route) → void - Adds a route definition to the router.
-
any(
String path, T value) → void - Adds a route definition for all HTTP methods (GET, POST, PUT, etc.).
-
anyOf(
Set< Method> methods, String path, T value) → void - Adds a route definition for a set of HTTP methods.
-
attach(
String path, Router< T> subRouter, {bool consume = false}) → void -
Attaches a sub-router to this router at the specified
path. -
call(
Request req) → FutureOr< Result> -
Available on RelicRouter, provided by the RouterHandlerEx extension
Similar to HandlerObject this extension allows a Router to be callable like a Handler. -
connect(
String path, T value) → void - Adds a route definition for the CONNECT HTTP method.
-
delete(
String path, T value) → void - Adds a route definition for the DELETE HTTP method.
-
get(
String path, T value) → void - Adds a route definition for the GET HTTP method.
-
group(
String path) → Router< T> - Create and attach a subrouter for a path. If one already exists they are merged.
-
head(
String path, T value) → void - Adds a route definition for the HEAD HTTP method.
-
inject(
InjectableIn< Router< injectable) → voidT> > -
Injects an
injectableinto the router. Unlike add it allows theinjectableobject to determine how to be mounted on the router. -
injectAt(
String path, InjectableIn< Router< injectable) → voidT> > -
Available on Router<
InjectsT> , provided by the RouteEx extensioninjectableatpath -
lookup(
Method method, String path, {bool backtrack = true}) → LookupResult< T> -
Looks up a route matching the provided
path. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
options(
String path, T value) → void - Adds a route definition for the OPTIONS HTTP method.
-
patch(
String path, T value) → void - Adds a route definition for the PATCH HTTP method.
-
post(
String path, T value) → void - Adds a route definition for the POST HTTP method.
-
put(
String path, T value) → void - Adds a route definition for the PUT HTTP method.
-
toString(
) → String -
A string representation of this object.
inherited
-
trace(
String path, T value) → void - Adds a route definition for the TRACE HTTP method.
-
use(
String path, T map(T)) → void - Adds a middleware function to the router.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited