@showbridge/lib
Version:
Main library for showbridge protocol router
21 lines (20 loc) • 688 B
JavaScript
import { has } from 'lodash-es';
import { logger } from '../utils/index.js';
import Trigger from './trigger.js';
class HTTPRequestTrigger extends Trigger {
test(msg) {
let matched = true;
if (msg.messageType !== 'http') {
logger.error('trigger: http-request only works with http messages');
return false;
}
if (has(this.params, 'path')) {
matched = matched && this.params.path === msg.path;
}
if (has(this.params, 'method')) {
matched = matched && this.params.method.toUpperCase() === msg.method.toUpperCase();
}
return matched;
}
}
export default HTTPRequestTrigger;