UNPKG

512 BJavaScriptView Raw
1'use strict';
2
3const debug = require('debug')('clientlinker-flow-confighandler');
4
5module.exports = function confighandler(runtime, callback) {
6 const client = runtime.client;
7 const options = client.options;
8 if (!options.confighandler) return callback.next();
9
10 const handler = options.confighandler[runtime.method];
11
12 if (typeof handler == 'function') {
13 return handler(runtime.query, runtime.body, runtime.options);
14 } else {
15 debug('config no handler:%s', runtime.method);
16 return callback.next();
17 }
18};