javascript - REST vs angular-resource's design philosophy -


recently i've been involved in building restful application using php , angularjs gui layer.

i using angular-resource managing objects , various urls<->actions of application.

however got questioned thought standardized way of writing restful's urls , way angular-resource manipulates crafted objects.

for instance, got resource follow :

var foos = $resource('/api/foos/:id'); 

all actions in api involves getting, deleting, , updating object deals url syntax :

/api/resources/:id

and data manipulated regarding action perform sent through post channel.

however if write,

var foo = foos.get({id:12}); 

it makes sense , url /api/foos/12 fetches foo id of 12. then

foos.get({id:12}, function (f) {   f.value = 12;   f.$save(); }); 

sends post data representing foo object using application/json representation url of form /api/foos while should /api/foos/12

does delt sort of question ? explicit syntax every foo object should accessible via unique url in restful application's paradigm.

how should change resources in gui have explicit urls regardless of action want perform on objects ?

e.g.

f.$save(); // should request url /api/foos/12 

i think need write {id:'@id} second parameter of resource definition..


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -