-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a wrapper around the various transporters that runs it thro…
…ugh a proxy (#133) * Introduce a wrapper around the various transporters that runs it through a proxy. * remove the proxy support for JSONP, and instead throw an error.
- Loading branch information
Showing
12 changed files
with
288 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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,37 @@ | ||
'use strict'; | ||
|
||
/*jslint latedef:false*/ | ||
|
||
(function() { | ||
angular.module('o19s.splainer-search') | ||
.factory('HttpProxyTransportFactory', [ | ||
'TransportFactory', | ||
'$http', | ||
'HttpJsonpTransportFactory', | ||
HttpProxyTransportFactory | ||
]); | ||
|
||
function HttpProxyTransportFactory(TransportFactory, $http, HttpJsonpTransportFactory) { | ||
var Transport = function(options) { | ||
TransportFactory.call(this, options); | ||
}; | ||
|
||
Transport.prototype = Object.create(TransportFactory.prototype); | ||
Transport.prototype.constructor = Transport; | ||
|
||
Transport.prototype.query = query; | ||
|
||
function query(url, payload, headers) { | ||
var transport = this.options().transport; | ||
|
||
// It doesn't make sense to use JSONP instead of GET with a proxy | ||
if (transport instanceof HttpJsonpTransportFactory) { | ||
throw new Error('It does not make sense to proxy a JSONP connection, use GET instead.'); | ||
} | ||
url = this.options().proxyUrl + url; | ||
return transport.query(url, payload, headers); | ||
} | ||
|
||
return Transport; | ||
} | ||
})(); |
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.