Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add middleware for outgoing messages #20

Closed
mbrevoort opened this issue Jul 30, 2016 · 5 comments
Closed

Add middleware for outgoing messages #20

mbrevoort opened this issue Jul 30, 2016 · 5 comments
Labels
enhancement M-T: A feature request for new functionality

Comments

@mbrevoort
Copy link
Contributor

Processed for msg.say and msg.respond, not sure what the API looks like yet but would be nice to be able to msg.say({ key , params}) and have it look that up in a language file

@mbrevoort
Copy link
Contributor Author

If we would add middleware for outgoing messages, how would we distinguish from incoming middleware which is currently slapp.use.

Something like this?

slapp.useIn and slapp.useOut
or
slapp.useIncoming and slapp.useOutgoing

@mbrevoort
Copy link
Contributor Author

Also, would this be triggered off of msg.say and msg.respond or a wrapper around slapp.client so that any call would proxy through the middleware allowing you to match in any criteria that matches certain API calls like chat.postMessage or reactions.add. If it was a proxy to slapp.client it would be a good way to capture and track metrics. Also, incoming middleware has access everything incoming as well.

@selfcontained
Copy link
Contributor

more options: slapp.in() and slapp.out() - might be too vague?

@curtisallen
Copy link
Contributor

It would be useful to define middleware on a per matcher basis similar to express.js

router.METHOD(path, [callback, ...] callback)
You can provide multiple callbacks, and all are treated equally, and behave just like middleware

This way you could

slapp.command('/foo', myMiddleware, (msg) => {
  // do stuff
})

slapp.action('someaction', 'answer', myMiddleware, (msg) => {
 // do stuff
})

function myMiddleware(msg, next} {
  // do stuff
  next()
}

@selfcontained selfcontained added the enhancement M-T: A feature request for new functionality label Apr 29, 2017
@shaydewael
Copy link
Contributor

In Bolt v1, we added the ability to pass a post-processing function into next() (which must call done()). Post-processing functions are called after all of the listener middleware on the way back up the execution chain (to do things like handle propagated errors)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality
Projects
None yet
Development

No branches or pull requests

4 participants