[英]NodeJS Express recursive routes
Some website's APIs let you do something like this:一些网站的 API 可以让你做这样的事情:
Initial user's id their first friend, also a user
v v
GET /api/users/54282/friends/0/friends/0
^
first item in array, would also be a user
Rather than而不是
Initial user's id
v
GET /api/users/54282/friends
Look at friends[0].id to get the first friend's id
First friend's id
v
GET /api/users/97420/friends
Look at friends[0].id to get the first friend's id
First friend's id
v
GET /api/users/31230
Another example although i'm not sure if Github allows this另一个例子虽然我不确定 Github 是否允许这个
Get the 10th collaborator's repos
GET /api/users/sharedrory/repos/312388/collaborators/10/repos
How do would you implement something like this in express?你会如何在 express 中实现这样的东西?
It seems the term I wanted was "nested"/"nesting"看来我想要的术语是“嵌套”/“嵌套”
Rest with Express.js nested router https://gist.github.com/zcaceres/f38b208a492e4dcd45f487638eff716c Rest 带 Express.js 嵌套路由器https://gist.github.com/zcaceres/f38b208a492e4dcd45f487638eff716c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.