Comments (1)
Yes, order is a factor - it matches first to last.
In your first example: the id
parameter picks up the status
part of the path, and hence it stops looking for other routes to match.
If you really need to keep the order, it is possible, but I wouldn't recommend it in this case.
// This route will only match if the `id` parameter is an integer
router.get('/entity/:id(\\d+)', ApiClass.getById);
@koa/router uses path-to-regexp to parse route paths into regular expressions. If interested, you can read about "custom matching parameters" in the readme 🙂
from router.
Related Issues (20)
- Receive 404 with busyboy HOT 1
- Using two routers, the next bug of regular routing HOT 5
- [email protected] will cause error HOT 2
- Route followed by required verbs and handler syntax HOT 1
- .url() and other methods that take route names are awkward to use with nested routers because of name collisions HOT 2
- better to check path before register HOT 2
- Global middleware for 404 overwrites allowed methods response output HOT 2
- A catch-all 404 handler for koa? HOT 4
- [feat] ctx's key of _matchedRoute
- [fix] The directory in the API documentation does not work. HOT 1
- Support multiple hosts for routing without use of RegExp
- [feat] koa 相关库的介绍文档不够详细,如何使用 HOT 1
- [feat] add support for path-group style routing HOT 1
- [fix] Match the right controller when multiple routes matches without calling next() HOT 2
- [feat] Add request validation guard with jsonSchema
- [fix] router.use method doesn't work with RegExp
- [fix] router.use doesn't work with middleware.
- v11.0.2 is tagged as latest in npm, instead of v12.0.1 HOT 1
- [fix] ctx.request.body 不能设置类型标注
- [fix] @koa/router does not handle decoding URL with '+' character properly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.