route method

Linkable route (String pattern)

Adds a route that Controllers can be linked to.

Routers allow for multiple linked controllers. A request that matches pattern will be sent to the controller linked to this method's return value.

The pattern must follow the rules of route patterns (see also http://aqueduct.io/docs/http/routing/).

A pattern consists of one or more path segments, e.g. "/path" or "/path/to".

A path segment can be:

  • A literal string (e.g. users)
  • A path variable: a literal string prefixed with : (e.g. :id)
  • A wildcard: the character *

A path variable may contain a regular expression by placing the expression in parentheses immediately after the variable name. (e.g. :id(/d+)).

A path segment is required by default. Path segments may be marked as optional by wrapping them in square brackets [].

Here are some example routes:

    /users
    /users/:id
    /users/[:id]
    /users/:id/friends/[:friendID]
    /locations/:name([^0-9])
    /files/*

Implementation

Linkable route(String pattern) {
  var routeController = _RouteController(
      RouteSpecification.specificationsForRoutePattern(pattern));
  _routeControllers.add(routeController);
  return routeController;
}