titanous/mailman — pull request #79 by loopj (2013-08-10 00:52:02+00:00)
Title: Added support for message processing middleware

I've added support for message processing middleware. This allows you to execute code before and after each message is processed. Middleware is super useful for things like error handling and any other actions you need to do before/after each message is processed. I've used a middleware approach similar to the ones sidekiq and rack use.

Here's a reference implementation of a simple error handling middleware:

```ruby
# Make a simple error logging middleware
class ErrorLoggingMiddleware
def call(mail)
begin
yield
rescue
puts "There was an error processing this message!"
raise
end
end
end

# Add it to the middleware stack
Mailman.config.middleware.add ErrorLoggingMiddleware
Mailman::Application.run do
# app code here
end
```