Closed StarpTech closed 7 years ago
I create a PR https://github.com/hemerajs/hemera/pull/42
Solution:
hemera.add({
topic: 'test',
cmd: 'add'
}).use(function(req, resp, next) {
//process request
})
.end(function(req, cb) {
cb()
})
If you pass an error to the next function the request-response cycle is canceled and the error responded.
It would be nice to have the chance to define middleware only for specific
add
I prefer a chaining syntax instead parameter overloading.
Approach: Providing an interface to attach handlers to the
actMeta
object. When the add is called we could return an interface.Those handlers can be executed in serial when a message arrived https://github.com/hemerajs/hemera/blob/master/packages/hemera/lib/index.js#L510.