middleware

Allow all requests for a given resource to be intercepted by a chain of middlewares, each of which may choose to mess with the request or response, e.g. behave like a vcr (the main motivation for this pr).