A monadic abstraction for requests and middlewares