RESTful 应用程序的更好 url 结构是什么?

What is the better url structure for RESTful application?

我们有一个 Laravel 后端和 Angular2 前端。

哪个URL结构更好:

what/:id/action
示例:course/2/edit

(I've seen this version in most blogs and it's Laravel's default convention)

what/action/:id
示例:course/edit/2

This version seems to have better protection from "overlapping"
what/:id/action would run into an issue if I would have
course/categories because categories would fall into :id slot.


所有这些 URL 共享相同的方法 (GET),因此结构本身需要足够好。

重叠问题可以通过按正确顺序排列路线或使用
pathMatch: 'full' 来解决,但这意味着模式本身不够好。

抱歉这个有点主观的问题,感谢您提前抽出时间。

最好的方法是使用标准 RESTful controllers and routes:

GET         /photos
GET         /photos/create
POST        /photos
GET         /photos/{photo}
GET         /photos/{photo}/edit
PUT/PATCH   /photos/{photo}
DELETE      /photos/{photo}