vendredi 22 mai 2015

How to custom ember data's restful URL and modify the HTTP method

I use ember data in my project. I konw the REST adapter's URL conventions is follow

Action  | HTTP Verb| URL
------- | ---------|---------
Find    | GET      | /posts/1
Find All| GET      | /posts
Update  | PUT      | /posts/1
Create | POST      | /posts
Delete | DELETE    |/posts/1

But I got a backend's URL like this

Action  | HTTP Verb| URL
------- | ---------|---------
Find    | GET      | /posts/show/1
Find All| GET      | /posts/list
Update  | POST     |  /posts/update
Create | POST      | /posts/add
Delete | POST      | /posts/delete

The URL and HTTP verb are both different. I know that I can custom the URL with buildURL (modelName, id, snapshot, requestType, query).I think I can check the requestType and hardcode the URL. I wanna know is there a elegant way to custome the URL and modify the HTTP method? Thank you.

Ember version 1.12.0 Ember-Cli version 0.2.5




Aucun commentaire:

Enregistrer un commentaire