Adds `middleware` method to create Connect middleware

Implements `middleware()` method to create a function that can be used as Connect middleware.