route method
Serves methods at path, relative to this router.
final notes = Router()
..route('/', get(listNotes).post(writeNote))
..route('/{id}', get(readNote));
Implementation
void route(String path, MethodRouter methods) {
_requireOpen();
if (methods.handlers.isEmpty) {
throw ArgumentError('route "$path" was given no handlers');
}
for (final entry in methods.handlers.entries) {
final route = Route(entry.key, path, entry.value);
internals.routes.add(route);
internals.declarations.add(route);
}
}