UNPKG

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