new feature: specifying the scope of middlewares through the constructor