fixes
2c44ec0
] - fix: ensure ctx._matchedRoute and ctx._matchedRouteName to be correct (#7) (Yiyu He <>)
features
f0b29ec
] - refactor: use class instead prototype (#4) (fengmk2 <fengmk2@gmail.com>)features
1a0036a
] - feat: add routerPath to respond to routerName (#2) (Khaidi Chu <i@2333.moe>)others
ff723fd
] - chore: add koa-router license (#3) (fengmk2 <fengmk2@gmail.com>)features
b318dd5
] - feat: add egg-router (dead-horse <>)
fixes
b3db7b4
] - fix: add missing dependencies koa-convert (dead-horse <>)
c280336
] - fix: only support node@8 (dead-horse <>)
7a887a2
] - fix: update license (dead-horse <>)
others
ae40168
] - docs: clean doc (dead-horse <>)
e4f21a8
] - chore: fix history (dead-horse <>)
others
d6496e0
] - refactor: rename to @eggjs/router (dead-horse <>)
layer.name
added to ctx
at ctx.routerName
during routing #412(.*)
as a prefix to all routers nested with .use that did not pass an explicit prefix string as the first argument. This resulted in routes being matched that should not have been, included the running of multiple route handlers in error. #369 and #410 include information on this issue._matchedRouteName
to context #337.use()
(or .get()
,
etc.), which matches Express 4 API.ctx._matchedRoute
.Private API changed to separate context parameter decoration from route
matching. Router#match
and Route#match
are now pure functions that return
an array of routes that match the URL path.
For modules using this private API that need to determine if a method and path
match a route, route.methods
must be checked against the routes returned from
router.match()
:
var matchedRoute = router.match(path).filter(function (route) {
return ~route.methods.indexOf(method);
}).shift();
405, 501, and OPTIONS response handling was moved into separate middleware
router.allowedMethods()
. This resolves incorrect 501 or 405 responses when
using multiple routers.
4.x is mostly backwards compatible with 3.x, except for the following:
new
and app
returns the router instance,
whereas 3.x returns the router middleware. When creating a router in 4.x, the
only time router middleware is returned is when creating using the
Router(app)
signature (with app
and without new
).