@themost/web
Version:
MOST Web Framework 2.0 - Web Server Module
42 lines (37 loc) • 1.02 kB
JavaScript
// @themost-framework 2.0 Codename Blueshift Copyright (c) 2017-2025, THEMOST LP All rights reserved
var _ = require('lodash');
/**
* @class
* @param {Function} callable
* @param {*=} params
* @constructor
*/
function HttpConsumer(callable, params) {
/**
* IMPORTANT NOTE FOR HTTP CONSUMERS
* (this an instance of HttpContext)
var consumer = new HttpConsumer(function() {
console.log(this.request.url)
});
*/
if (!_.isFunction(callable)) {
throw new TypeError('Consumer must be a function');
}
/**
* @type {Function}
*/
this.callable = callable;
/**
* Gets or sets the parameters associated with this consumer
*/
this.params = params;
}
/**
* @param {*} context
* @param {...*} args
*/
// eslint-disable-next-line no-unused-vars
HttpConsumer.prototype.run = function(context, args) {
return this.callable.apply(context, Array.prototype.slice.call(arguments));
};
module.exports.HttpConsumer = HttpConsumer;