DRYing controllers and middlewares