Wednesday, March 1, 2017

What is the better url structure for RESTful application?

We have a Laravel back-end and Angular2 for front-end.

Which URL structure is better:

what/:id/action
Example: course/2/edit

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

or

what/action/:id
Example: 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.


All of these URLs share the same method (GET) so the structure itself needs to be good enough.

The overlapping issue could be solved with ordering the routes in right order or using
pathMatch: 'full' but that would mean that the pattern itself is not good enough.

Sorry for the kinda subjective question, and thank you for your time in advance.




via Mihailo

Advertisement