estrada 0.9.7 copy "estrada: ^0.9.7" to clipboard
estrada: ^0.9.7 copied to clipboard

Minimalistic, fast route matcher for Dart (path + query parsing).

πŸ›£ Estrada #

A blazing fast route matcher for Dart.
Focuses only on path + query parsing β€” no servers, no DI, no middleware.
You can compose it with any HTTP library, CLI tool, or custom framework.


πŸš€ Example #

import 'package:estrada/estrada.dart';

class UserRoute extends EstradaRoute {
  const UserRoute({required super.route});
}

void main() {
  final estrada = Estrada<UserRoute>(
    routes: [
      const UserRoute(route: 'v1/users'),
      const UserRoute(route: 'v1/users/:userId'),
      const UserRoute(route: 'v1/tags/:tagId'),
      const UserRoute(route: 'v1/status'),
    ],
  );

  final samples = [
    'v1/users',
    'v1/users/42',
    'v1/users/42/posts',
    'v1/posts/99',
    'v1/posts/99/comments',
    'v1/tags',
    'v1/tags/123?q=hello',
    'v1/auth/login',
    'v1/auth/logout',
    'v1/status',
  ];

  for (final url in samples) {
    final result = estrada.match(url);
    if (result != null) {
      print('βœ… $url β†’ matched ${result.route.route}, '
          'paths: ${result.paths}, queries: ${result.queries}');
    } else {
      print('β›” $url β†’ not found');
    }
  }
}

Output:

βœ… v1/users β†’ matched v1/users, paths: {}, queries: {}
βœ… v1/users/42 β†’ matched v1/users/:userId, paths: {userId: 42}, queries: {}
β›” v1/users/42/posts β†’ not found
β›” v1/posts/99 β†’ not found
β›” v1/posts/99/comments β†’ not found
β›” v1/tags β†’ not found
βœ… v1/tags/123?q=hello β†’ matched v1/tags/:tagId, paths: {tagId: 123}, queries: {q: hello}
β›” v1/auth/login β†’ not found
β›” v1/auth/logout β†’ not found
βœ… v1/status β†’ matched v1/status, paths: {}, queries: {}

πŸ“¦ Installation #

Add to your pubspec.yaml:

dependencies:
  estrada: ^0.9.7

Then run:

dart pub get

🧱 Philosophy #

Estrada does one thing: route matching.
That’s it. No servers, no DI, no middleware.
You can freely compose it with any HTTP library, CLI tool, or custom framework.


0
likes
160
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

Minimalistic, fast route matcher for Dart (path + query parsing).

Repository (GitHub)
View/report issues

Topics

#routing #http #cli #matcher

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

meta

More

Packages that depend on estrada