estrada 0.9.7
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.