export function watch(req, res, next) {
    res.success = success.bind({res:res, req:req});
    
    return next();
}

/**
 * 中间件正确返回方法
 * @param data 
 */
function success(data) {
    let resultPack;
    if (data ) {
        if ( data.success === undefined || data.success === true ) {
            resultPack = {data, success:true, code:200};
        }
        else {
            resultPack = data;
        }
    }else {
        resultPack = {code:500, success:false, msg:'result is null'};
    }
    this.res.send(resultPack);
}

