return object containing the middleware

This is to be able to return additional methods and attributes without
having to resort to attaching them to the middleware itself.