spry_router 1.2.1 spry_router: ^1.2.1 copied to clipboard
A request router for the Spry web framework that supports matching handlers from path expressions.
Changelog #
1.2.1 (2023-03-24) #
Bug Fixes #
- deps: Adapt to Spry 2.x (da26a4e)
1.2.0 (2023-03-22) #
Features #
- Router: Add router extendsion (585577a)
1.1.0 (2023-03-17) #
Features #
- Adapt to spry 2.0 (e1a8b70)
1.0.0 (2023-03-15) #
⚠ BREAKING CHANGES #
- Fix wrong version dependencies
Bug Fixes #
- Fix wrong version dependencies (e65b8d3)
0.5.0 (2023-03-14) #
Features #
- Add use and param extension for middleware and handler (54a2379)
- MiddlewareNext -> Next (80b3da7)
- router: Allow duplicate routes to be added to the router (d08f181)
Bug Fixes #
- spry_router: Fix the
mount
not inject route params bug. (8f5c314)
0.4.1 #
Update readme.
0.4.0 #
Adapt to the new spry
0.4.0 version.
0.3.2 #
Allow duplicate routes to be added to the router.
0.3.1 #
Fix the mount
not inject route params bug.
0.3.0 #
BREAKING CHANGE #
Router Prefix
The Router
class not longer has the prefix
property.
// Before
final router = Router('/api');
// Now
final router = Router();
Router Mount
Proxy forwarding a prefixed request to the unified handler/router via mount
. Previously, it could only be forwarded to the handler, but now it supports forwarding to the router.
// Before
router.mount('/api', handler);
// Now
router.mount('/api', handler: handler);
router.mount('/api', router: router);
New Features #
Merge Router
The Router
class now supports merging multiple routers into one.
final router = Router();
router.merge(router1);
router.merge(router2);
Router handle
Previously, Router could only be used as a standard Spry handler, which caused many problems, such as path matching not working properly, or prefix requiring a root-based path!
Now, no more, we added the handle method to satisfy the above customization process.
Nesting Router #
Nested routers are now supported, and the routes are independent, and they can be nested for merging, mounting, and other operations:
final r1 = Router();
final r2 = Router();
r1.mount('r2', router: r2);
r2.mount('r1', router: r1);
r1.merge(r2);
r2.merge(r1);
r1.mount('r1', router: r1);
r2.mount('r2', router: r2);
r1.merge(r1);
r2.merge(r2);
Yes, you read that right, Routers can mount and merge with each other!
By mounting each other, you can create a routing path that repeats path segments infinitely long! But that's not what this feature wants you to accomplish, what we added this feature is to allow you to modularize your Spry program, and then support whatever prefix path you want to mount that module on!
0.2.0 #
- BREAKING CHANGE:
mount
now needs aprefix
argument. Router
public the propertyprefix
.
0.1.1 #
Param Middleware #
Param middleware now supports use
method to add middleware to a specific param.
final ParamMiddleware middleware.use(otherMiddleware);
Handler extension #
Spry handler supported use
and param
methods to add middleware and param middleware to a handler.
final Handler handler.use(middleware).param(paramMiddleware);
0.1.0 #
- Update
spry
to0.1.3
. - Fix docs typo.
- BREAKING CHANGE:
ParamMiddlewareNext
is nowParamNext
.
0.0.3 #
- Hidden
RouterImpl
class. - Not found default changed to
HttpException.notFound()
.
0.0.2 #
Update deps.
0.0.1 #
Spry makes it easy to build web applications and API applications in Dart with middleware composition processors. This package provides Spry with request routing handlers that dispatch requests to handlers by routing matching patterns.