The HTTP method PUT means resource creation or replacement at some given URL.
Think files, for example. If you upload a file to S3 at some URL, you want either to create the file at that URL or replace an existing file if there's one. That is PUT.
Now let's say a web application has an
Invoicemodel with apaidflag that indicates whether the invoice has been paid. How do you set that flag in a RESTful way? Submittingpaid=1via PUT to/invoices/:iddoes not conform to the semantics, because such request would not be sending a complete representation of the invoice for replacement....
In practice, as you see, PATCH suits everyday web programming way better than PUT for updating resources. In Ruby on Rails it corresponds naturally to the way we use
update_attributesfor updating records.Thus, PATCH is going to be the primary method for updates in Rails 4.0.
Tuesday, February 28, 2012
REST's fifth HTTP method: PATCH?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment