[ 
https://issues.apache.org/jira/browse/RAVE-1048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13750449#comment-13750449
 ] 

Rohit Kalkur commented on RAVE-1048:
------------------------------------

Chris,

By default, when the ResourceName.$save(params) method is called on an Angular 
Resource, it first checks to see if the params object has an 'id' property. If 
it has an id, it triggers a POST request to the /api/resourceEndPoint/:id route

If the params object does not have an 'id' property, it triggers a POST request 
to the /api/resourceEndPoint/ route.

I really like the flexibility of this implementation because the Resource is 
able to determine which type of request to send by calling just a single 
method, the $save() method. 

I am currently implementing the CurrentPageCtrl on the Angular side, and I have 
a controller that is responsible for editing an existing page or adding a page 
(and this is determined by checking the scope to see if a page is defined or 
not). If we just use the PUT implementation for update as you suggest, I would 
have to add an additional check in the Angular code to see if the page model 
for that controller has an 'id' property defined or not, and then calling 
either save() or update(). Having a call like save(), which is already agnostic 
to either update or create, is more flexible and cleaner (less 
conditional-checking code to write).

-Rohit K

                
> Have update rest methods accept both put and post requests.
> -----------------------------------------------------------
>
>                 Key: RAVE-1048
>                 URL: https://issues.apache.org/jira/browse/RAVE-1048
>             Project: Rave
>          Issue Type: Sub-task
>          Components: rave-core
>            Reporter: Erin Noe-Payne
>             Fix For: 0.23
>
>
> Angular's $resource service uses post methods to save new or updated 
> resources. For simplicity, we should update the rest api endpoints so that 
> update methods accept PUT or POST requests.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to