Simplify Master#api
This commit is contained in:
parent
801d1a5d49
commit
e66c1145d5
21
lib/cylon.js
21
lib/cylon.js
|
@ -101,21 +101,14 @@ var Cylon = (function() {
|
|||
Master.prototype.api = function(opts) {
|
||||
if (opts == null) { opts = {}; }
|
||||
|
||||
var host = opts.host || this.api_config.host,
|
||||
port = opts.port || this.api_config.port,
|
||||
auth = opts.auth || this.api_config.auth,
|
||||
cert = opts.cert || this.api_config.cert,
|
||||
cors = opts.CORS || this.api_config.CORS,
|
||||
key = opts.key || this.api_config.key;
|
||||
var keys = ['host', 'port', 'auth', 'cert', 'CORS', 'key'];
|
||||
|
||||
this.api_config = {
|
||||
host: host,
|
||||
port: port,
|
||||
cert: cert,
|
||||
key: key,
|
||||
auth: auth,
|
||||
CORS: cors
|
||||
};
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
if (typeof opts[key] !== "undefined") {
|
||||
this.api_config[key] = opts[key];
|
||||
}
|
||||
}
|
||||
|
||||
return this.api_config;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue