bind<T extends Object> static method

void bind<T extends Object>(
  1. String param,
  2. RouteBinder<T> resolve
)

turn the route param param into a value before the controller runs. resolve gets the raw text and gives the value, or null when there is none: then the request gets 404. read it with req.bound<T>(param), or add a controller parameter of type T. call it before the server starts.

Route.bind<User>('user', (String id) => User().find(id));
Route.get('users/{user}', (DoxRequest req, User user) => user);

Implementation

static void bind<T extends Object>(String param, RouteBinder<T> resolve) {
  _bindings[param] = RouteBinding(T.toString(), resolve);
}