Authored by 毕凯

api 支持签名

... ... @@ -12,6 +12,7 @@ const _ = require('lodash');
const log = require('./logger');
const cache = require('./cache');
const Timer = require('./timer');
const sign = require('./sign');
const config = require('../config/common');
const api = config.domains.api;
const serviceApi = config.domains.service;
... ... @@ -37,7 +38,7 @@ class Http {
const timer = new Timer();
const method = options.method || 'get';
log.info(`${method} api: ${options.url}?${qs.stringify(options.qs)}`);
log.info(`${method} api: ${options.url}?${qs.stringify(options.qs || options.form)}`);
timer.put('getApi');// 统计时间开始
return rp(options).then((result) => {
const duration = timer.put('getApi');// 统计时间结束
... ... @@ -132,7 +133,7 @@ class Http {
get(url, data, cacheOption) {
const options = {
url: `${this.ApiUrl}${url}`,
qs: data,
qs: data.client_secret ? data : sign.apiSign(data),
json: true,
gzip: true,
timeout: 3000
... ... @@ -154,7 +155,7 @@ class Http {
post(url, data) {
const options = {
url: `${this.ApiUrl}${url}`,
form: data,
form: data.client_secret ? data : sign.apiSign(data),
method: 'post',
json: true,
timeout: 3000
... ...