REST: post vs posts & new vs create

When you design a URL scheme for your application, what rules do you use?

  • example.com/post/ or example.com/posts/ for a list of posts
  • example.com/post/new/ or example.com/post/create/ for a new post
  • example.com/posts/ + example.com/post/23/ or example.com/post/ + example.com/post/23/ for a list and detail of the message?
  • example.com/post/23 or example.com/post/23/ for details
  • example.com/post/edit/23/ or example.com/post/23/edit/ for editing.

I prefer: / post / for a list, / post / 23 / for details, / post / 23 / edit / for editing, just b / c. I can very easily work with this URL manually in a browser. I am wrong? Suggest me please.

Thank.

+3
source share
2 answers

, HTTP POST . , POST example.com/customer. , , GET example.com/customer/{your }. , GET example.com/customer. , , , PUT example.com/customer/{your }

, , , ( ) URL-. . , - example.com/edit/23, HTTP PUT example.com/23 ( example.com/customers/23).

RESTful/REST RESTful.

PUT vs POST REST POST PUT ( ).

URL- RESTful LinkedIn.

+3

:

  • GET/
  • GET/posts/new HTML 'static' ( "ajax" "" )
  • POST/ ('action' attr )
  • GET/posts/23 ( !)
  • GET /posts/ 23/edit HTML "_method = PUT" PUT
  • PUT /posts/ 23 ('action' attr )
  • DELETE/posts/23 ('inline' HTML- '_method = DELETE' )
  • POST /posts/ 23 PUT DELETE .

/posts/or/posts/ 23/, ( ) . /posts ( /posts.html) , /posts.xml XML,/posts.json "ajax" /posts.smth_else smth else:) . ( ), .

0

Source: https://habr.com/ru/post/1751979/


All Articles