assert if the rest wrappers are misused
This commit is contained in:
@@ -62,6 +62,11 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
|
||||
// XHR wrapper to set the auth header
|
||||
function get(url, config, callback) {
|
||||
if (arguments.length !== 3) {
|
||||
console.error('GET', arguments);
|
||||
throw('Wrong number of arguments');
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
config.headers = config.headers || {};
|
||||
config.headers.Authorization = 'Bearer ' + token;
|
||||
@@ -72,6 +77,11 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}
|
||||
|
||||
function head(url, config, callback) {
|
||||
if (arguments.length !== 3) {
|
||||
console.error('HEAD', arguments);
|
||||
throw('Wrong number of arguments');
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
config.headers = config.headers || {};
|
||||
config.headers.Authorization = 'Bearer ' + token;
|
||||
@@ -82,6 +92,11 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}
|
||||
|
||||
function post(url, data, config, callback) {
|
||||
if (arguments.length !== 4) {
|
||||
console.error('POST', arguments);
|
||||
throw('Wrong number of arguments');
|
||||
}
|
||||
|
||||
data = data || {};
|
||||
config = config || {};
|
||||
config.headers = config.headers || {};
|
||||
@@ -93,6 +108,11 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}
|
||||
|
||||
function put(url, data, config, callback) {
|
||||
if (arguments.length !== 4) {
|
||||
console.error('PUT', arguments);
|
||||
throw('Wrong number of arguments');
|
||||
}
|
||||
|
||||
data = data || {};
|
||||
config = config || {};
|
||||
config.headers = config.headers || {};
|
||||
@@ -104,6 +124,11 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
}
|
||||
|
||||
function del(url, config, callback) {
|
||||
if (arguments.length !== 3) {
|
||||
console.error('DEL', arguments);
|
||||
throw('Wrong number of arguments');
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
config.headers = config.headers || {};
|
||||
config.headers.Authorization = 'Bearer ' + token;
|
||||
|
||||
Reference in New Issue
Block a user