Decorator to add middleware