This repository was archived by the owner on Jan 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Api host proxy mixin #99
Merged
pixelhandler
merged 5 commits into
pixelhandler:master
from
realxsnl:api-host-proxy-mixin
Sep 10, 2016
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
08d281c
Sane default URL for adapter(s). Removes API_HOST_PROXY.
aars 6222a72
Puts generated url back into blueprint
aars 26165c1
API_HOST_PROXY as (example) mixin.
aars e1d9b87
Adds comment about url property (adapter-blueprint)
aars 0e3e31b
Puts config import statement back
aars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| @module ember-jsonapi-resources | ||
| @submodule adapter-api-host-proxy-mixin | ||
| **/ | ||
| import Ember from 'ember'; | ||
|
|
||
| /** | ||
| Mixin to provide url rewrite for proxied api. Mostly used as example. | ||
|
|
||
| @class AdapterApiHostProxyMixin | ||
| @static | ||
| */ | ||
| export default Ember.Mixin.create({ | ||
| fetchUrl: function(url) { | ||
| const config = this.container.lookupFactory('config:environment'); | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(host, proxy); | ||
| } | ||
| return url; | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'author', | ||
|
|
||
| url: config.APP.API_PATH + '/authors', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'author' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'comment', | ||
|
|
||
| url: config.APP.API_PATH + '/comments', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'comment' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'commenter', | ||
|
|
||
| url: config.APP.API_PATH + '/commenters', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'commenter' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'employee', | ||
|
|
||
| url: config.APP.API_PATH + '/employees', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'employee' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'picture', | ||
|
|
||
| url: config.APP.API_PATH + '/pictures', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'picture' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,6 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
| import AuthorizationMixin from '../mixins/authorization'; | ||
|
|
||
| export default ApplicationAdapter.extend(AuthorizationMixin, { | ||
| type: 'post', | ||
|
|
||
| url: config.APP.API_PATH + '/posts', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'post' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,5 @@ | ||
| import ApplicationAdapter from './application'; | ||
| import config from '../config/environment'; | ||
|
|
||
| export default ApplicationAdapter.extend({ | ||
| type: 'product', | ||
|
|
||
| url: config.APP.API_PATH + '/products', | ||
|
|
||
| fetchUrl: function(url) { | ||
| const proxy = config.APP.API_HOST_PROXY; | ||
| const host = config.APP.API_HOST; | ||
| if (proxy && host) { | ||
| url = url.replace(proxy, host); | ||
| } | ||
| return url; | ||
| } | ||
| type: 'product' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aars thanks for adding this as a mixin :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My pleasure. When I find the time I'll look through all the docs. Those needs some touching up I reckon.