Koa Trie Router
Routes are orthogonal and strict, so the order of definition doesn't matter.
Unlike regexp routing, there's no wildcard routing and you can't
next to the next matching route.
See routington for more details.
- Koa@1 is compatible with
1.x.xversions of Trie-router
- Koa@2 is compatible with
- Express-style routing using
- Named URL parameters
- Responds to
OPTIONSrequests with allowed methods
- Multiple route middleware
- Multiple routers
- Nestable routers
405 Method Not Allowedsupport
501 Not Implementedsupport
const Koa =const Router =let app =let router =routerappapp
Handles all requests
Handles requests only by one HTTP method
Handles requests only by one HTTP method and one route
Like Express, all routes belong to a single middleware.
You can use
koa-mount for mounting of multiple routers:
const Koa =const mount =const Router =let app =let router1 =let router2 =router1router2appapp
Checks if the server implements a particular method and returns
This is not middleware, so you would have to use it in your own middleware.
ctx.request.params will be defined with any matched parameters.
The middleware throws an error with
code MALFORMEDURL when it encounters
a malformed path. An application can try/catch this upstream, identify the error
by its code, and handle it however the developer chooses in the context of the
application- for example, re-throw as a 404.
For path definitions, see routington.