...
|
...
|
@@ -20,12 +20,23 @@ util.inherits(Interfacer,Emitter); |
|
|
|
|
|
Interfacer.prototype.register = function(mos) {
|
|
|
var me=this,name=mos.namespace;
|
|
|
if(!name){
|
|
|
console.info(" Interfacer name can not empty");
|
|
|
}
|
|
|
for(var key in mos.apis){
|
|
|
var name_key=name+"_"+key;
|
|
|
if(me.isExisted(name_key)){
|
|
|
console.info("can not add repeat Interfacer key,please checkout");
|
|
|
}
|
|
|
/*需要进行验证判断*/
|
|
|
me.apis[name+"_"+key]=mos.apis[key];
|
|
|
me.apis[name_key]=mos.apis[key];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Interfacer.prototype.isExisted=function(key){
|
|
|
return !!this.apis[key];
|
|
|
};
|
|
|
|
|
|
function __requestApi(config, apiOpt, req, callback){
|
|
|
var me=this;
|
|
|
if (typeof apiOpt == "function") {
|
...
|
...
|
@@ -52,6 +63,9 @@ function __requestApi(config, apiOpt, req, callback){ |
|
|
if(_.isPlainObject(apiOpt.params)){
|
|
|
for(var name in apiOpt.params){
|
|
|
var param=apiOpt.params[name];
|
|
|
if(param.default){
|
|
|
data[name]=param.type(param.default);
|
|
|
}
|
|
|
if(req.param(name)){
|
|
|
data[name]=param.type(req.param(name));
|
|
|
}
|
...
|
...
|
|