Optimize Router matching with prefix Trie filter (#509) This commit replaces the (N)$ linear route iteration with a fast-path Trie filter. Instead of checking every registered route's RegExp against the incoming request, the Router now builds a prefix tree using the literal, non-variable segments of each route. When a request is received, the Router walks the Trie to collect only routes that exactly match the static prefix of the request path. It then evaluates the original RegExp match only on those isolated candidates. This provides (L)$ routing candidate filtration for massive APIs while maintaining 100% exact backward compatibility (preserving exact regex extraction, nested routers, and exact positional priority). Performance Metrics (10k routes across 100 controllers): | Metric | Before (Linear) | After (Trie) | Speedup | | :--- | :--- | :--- | :--- | | Worst-Case Match | 902.19 μs | 3.20 μs | ~281x Faster | | 404 (Not Found) | 734.12 μs | 0.45 μs | ~1,631x Faster |
Shelf makes it easy to create and compose web servers and parts of web servers. How?
It was inspired by Connect for NodeJS and Rack for Ruby.
See the package:shelf readme for more information.
| Package | Description | Issues | Version |
|---|---|---|---|
| shelf | A model for web server middleware that encourages composition and easy reuse. | ||
| shelf_packages_handler | A shelf handler for serving a packages/ directory. | ||
| shelf_proxy | A shelf handler for proxying HTTP requests to another server. | ||
| shelf_router | A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. | ||
| shelf_router_generator | A package:build-compatible builder for generating request routers for the shelf web-framework based on source annotations. | ||
| shelf_static | Static file server support for the shelf package and ecosystem. | ||
| shelf_test_handler | A Shelf handler that makes it easy to test HTTP interactions. | ||
| shelf_web_socket | A shelf handler that wires up a listener for every connection. |
For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.