问题
I am preparing my server-side application to handle PUT requests comming from an emberjs client (using ember-data). The client side application is not yet ready, so that I am not able to see the real requests (this in the hands of another developer). I nevertheless want to implement the server side. Where can I find information about the detailed format of PUT requests? I need two things:
- What is the
emberjsapplication going to send in theURL,headersandbodyof the request? - What is the
emberjsapplication expecting as reply to the thePUTrequest?
Here you can find a description of the REST interface which emberjs assumes, but I have been unable to find detailed information about PUT requests.
回答1:
Assuming you are using ember-data's default RESTAdapter, the following is the default format:
Let's say you are updating a post with the following attributes:
id: 50,
title: 'PUT requests'
body: 'Ember-data has a lot of potential'
isPublished: false
The PUT request will be made to the URL: '/posts/50'.
the payload submitted in the PUT request will be in the following format:
{
"post": {
"id": 50,
"title": "PUT requests",
"body": "Ember-data has a lot of potential",
"is_published": false
}
}
The RESTAdapter expects the response to be in the same format as above.
来源:https://stackoverflow.com/questions/15635328/format-of-data-in-put-requests