Router<T> class

An abstraction over complex Route trees. Use this instead of the raw API. :)

Implementers

Constructors

Router()
Provide a root to make this Router revolve around a pre-defined route. Not recommended.

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
middleware List<T>
read-only
mounted Map<Pattern, Router<T>>
read-only
routes List<Route<T>>
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addRoute(String method, String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to the given path for requests with the given method (case-insensitive). Provide '*' as the method to respond to all methods.
all(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to any request matching the given path.
chain(Iterable<T> middleware) → _ChainedRouter<T>
Prepends the given middleware to any routes created by the resulting router. [...]
clone() Router<T>
Returns a Router with a duplicated version of this tree.
delete(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to a DELETE request.
dumpTree({dynamic callback(String tree), String header: 'Dumping route tree:', String tab: ' '}) → void
Creates a visual representation of the route hierarchy and passes it to a callback. If none is provided, print is called.
enableCache() → void
Enables the use of a cache to eliminate the overhead of consecutive resolutions of the same path.
get(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to a GET request.
group(String path, void callback(Router<T> router), {Iterable<T> middleware, String name}) SymlinkRoute<T>
Creates a route, and allows you to add child routes to it via a Router instance. [...]
groupAsync(String path, FutureOr<void> callback(Router<T> router), {Iterable<T> middleware, String name}) Future<SymlinkRoute<T>>
Asynchronous equivalent of group.
Adds a route that responds to a HEAD request.
mount(String path, Router<T> router) SymlinkRoute<T>
Incorporates another Router's routes into this one's.
Generates a URI string based on the given input. Handy when you have named routes. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
options(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to a OPTIONS request.
patch(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to a PATCH request.
post(String path, T handler, {Iterable<T> middleware}) Route<T>
Adds a route that responds to a POST request.
put(String path, T handler, {Iterable<T> middleware}) Route
Adds a route that responds to a PUT request.
resolve(String absolute, String relative, List<RoutingResult<T>> out, {String method: 'GET', bool strip: true}) bool
Finds the first Route that matches the given path, with the given method.
resolveAbsolute(String path, {String method: 'GET', bool strip: true}) Iterable<RoutingResult<T>>
Returns the result of resolve with path passed as both absolute and relative.
resolveAll(String absolute, String relative, {String method: 'GET', bool strip: true}) Iterable<RoutingResult<T>>
Finds every possible Route that matches the given path, with the given method.
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited