What is a RESTful way to submit a form?

I understand most of how a RESTful website design should work, but when implementing a blog it is impossible to decide how best to submit a form for inserting a new blog post. Would example.com/posts/create be reasonable? It is like creating does not calm down, as if it were putting information in a URI, which should simply be represented by PUT / POST.

How can others do this?

+3
source share
3 answers

See Rails Routing for a presentation of Rails on this.

Verb   URL            Controller  Action   Used For
GET    /photos/new    Photos      new      return an HTML form for creating a new photo
POST   /photos        Photos      create   create a new photo

, GET /posts/new, , POST /posts, .

, , , . - () .

+2

, URL-, :

GET http://example.com/posts/createform
+2

Use POST to send the insert information, and then go to the page with the new identifier in the URL. You do not want to have new URL information, as the user updating the URL will publish twice.

0
source

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


All Articles