Is there any harm in using the typical GET action for PUT? (RESTfully speaking)

I have an action that does not require a form. So for this, you really only need one editing method, and not RESTful 'edit' → 'update'. Is there a reason not to do this or better?

def edit
  #Do a POST(PUT)
end
+3
source share
2 answers

The threat is that the user can easily go to this URL and perform a potentially destructive action.

/noform/edit   #URL typed by user => Action Performed
/noform/update #URL typed by user => Error is thrown, No Action Performed

Normal view scans GETfor server requests . It is assumed that any page that you can easily go to (or enter in the address bar) will not perform any functions that modify the data.

A POST , AJAX, , .

, "" PUT DELETE , .

, update edit - :

button_to "Add new tracker", noform_path, :method => :put

- , , , - . , , update .

+2

idempotent - , , ...

- RESTful HTTP Update, Rails , HTTP.

, . , .

+2

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


All Articles