roux 0.2.0 copy "roux: ^0.2.0" to clipboard
roux: ^0.2.0 copied to clipboard

A lightweight, fast, functional router for Dart with static, parameterized, and wildcard route matching.

example/main.dart

import 'package:roux/roux.dart';

void main() {
  final router = Router<String>(
    routes: {
      '/': 'root',
      '/users/all': 'usersAll',
      '/users/:id': 'userDetail',
      '/users/*': 'usersWildcard',
      '/*': 'globalFallback',
    },
  );

  describe(router, '/');
  describe(router, '/users/all');
  describe(router, '/users/42');
  describe(router, '/users/42/profile');
  describe(router, '/unknown/path');
}

void describe(Router<String> router, String path) {
  final match = router.match(path);
  if (match == null) {
    print('$path -> no match');
    return;
  }
  print('$path -> ${match.data} params=${match.params}');
}
1
likes
160
points
236
downloads

Publisher

verified publishermedz.dev

Weekly Downloads

A lightweight, fast, functional router for Dart with static, parameterized, and wildcard route matching.

Repository (GitHub)
View/report issues

Topics

#router #http #path-matching #trie

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

More

Packages that depend on roux