How to customize ember data restful url and change HTTP method

I am using ember data in my project. I know that the REST adapter URL conventions are as follows:

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 have a url like

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

      

The URL and the HTTP verb are both different. I know that I can customize the url with buildURL (modelName, id, snapshot, requestType, query)

. I think I can check the url of requestType and hardcode. I would like to know if there is an elegant way to customize the url and change the HTTP method? Thank.

Ember version 1.12.0 Ember-Cli version 0.2.5 Ember Data version 1.0.0-beta.17

+3


source to share


1 answer


I solve this by overriding the following method in the application adapter.

* `find()` * `createRecord()` * `updateRecord()` * `deleteRecord()` * `findAll()` * `findQuery()`



Gist here

+1


source







All Articles