ember-data-url-templates is an addon to allow building urls with url templates instead of
defining buildURL
as described in RFC #4.
ember-data-url-templates is under early development. Feedback is welcome, and of course, so are pull requests.
Url templates are compiled with geraintluff/uri-templates, which fully implements RFC 6570.
ember install ember-data-url-templates
- Node
>= 10
- ember-data-url-templates
>= 1.0.0
is known to work with ember-data>= 3.4
.
More in depth documentation can be found in the wiki.
// adapters/comment
import Ember from "ember";
import DS from "ember-data";
import UrlTemplates from "ember-data-url-templates";
export default DS.RESTAdapter.extend(UrlTemplates, {
urlTemplate: '{+host}/comments{/id}',
queryUrlTemplate: '{+host}/comments{?query*}',
createRecordUrlTemplate: '{+host}/users/{userId}/comments',
session: Ember.inject.service(),
urlSegments: {
userId() {
return this.get('session.userId');
}
}
});
git clone
this repositorynpm install
bower install
ember test
orember test --server
Here is a short list of things I'd like to support:
- Use a template provided by the API (like
links
)