Skip to content

Commit

Permalink
move it in conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed Mar 17, 2019
1 parent fe875db commit e0c4c12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/conditions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function register({ name, handler, schema }) {
conditions[name] = config => {
const validationResult = validate(config);
if (validationResult.isValid) {
if (handler.length === 2) {
return req => handler(req, config);
}

return handler(config);
}

Expand Down
6 changes: 0 additions & 6 deletions lib/gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ function bootstrap({ plugins, config } = {}) {
if (plugins && plugins.conditions && plugins.conditions.length) {
plugins.conditions.forEach(cond => {
log.debug('registering condition', cond.name);
if (cond.handler.length === 2) {
return conditionEngine.register({
...cond,
handler: config => req => cond.handler(req, config)
});
}
conditionEngine.register(cond);
});
}
Expand Down

0 comments on commit e0c4c12

Please sign in to comment.