I read rack middleware is for modifying the current request/response, but what about having a SendEmail middlewares which would look at env['user_id']
to send emails.
Let's assume the entire process (request + sending emails) will be async.
If you really want to do it in Goliath I'd suggest creating a plugin and doing it in there. Create a queue in the config and have the plugin pop items from the queue and send the mail.