Answer the question
In order to leave comments, you need to log in
What is the correct url construction principle?
In a situation where I need to get all the comments of the 1st post, which route would be more correct for this:
"/posts/1/comments" or "/comments?postId=1"?
And if the first option is correct, then what if, say, further, you need to display attachments in the comments?
Here it will probably be more pleasant to use not "/posts/1/comments/attachments", but "comments/id/attachments".
Which of the construction options to choose in what situations?
Answer the question
In order to leave comments, you need to log in
All options are correct. For the most part, the difference is that some addresses are easier to route to different microservices. Well, personal preference plays a big role.
UPD. And using get parameters in this form is considered bad manners, but mainly because it is more difficult to use the same type of addresses and "nested" resources
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question