Add force_ssl support

This commit is contained in:
Joseph Schorr 2015-02-04 12:03:07 -05:00
parent 98d63e00ee
commit 1255cb94ea

View file

@ -977,7 +977,7 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
return resource; return resource;
}; };
var buildUrl = function(path, parameters) { var buildUrl = function(path, parameters, opt_forcessl) {
// We already have /api/v1/ on the URLs, so remove them from the paths. // We already have /api/v1/ on the URLs, so remove them from the paths.
path = path.substr('/api/v1/'.length, path.length); path = path.substr('/api/v1/'.length, path.length);
@ -1017,6 +1017,11 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
} }
} }
// If we are forcing SSL, return an absolutel URL with an SSL prefix.
if (opt_forcessl) {
path = 'https://' + window.location.host + '/api/v1/' + path;
}
return url; return url;
}; };
@ -1155,8 +1160,8 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
var path = resource['path']; var path = resource['path'];
// Add the operation itself. // Add the operation itself.
apiService[operationName] = function(opt_options, opt_parameters, opt_background) { apiService[operationName] = function(opt_options, opt_parameters, opt_background, opt_forcessl) {
var one = Restangular.one(buildUrl(path, opt_parameters)); var one = Restangular.one(buildUrl(path, opt_parameters, opt_forcessl));
if (opt_background) { if (opt_background) {
one.withHttpConfig({ one.withHttpConfig({
'ignoreLoadingBar': true 'ignoreLoadingBar': true