Moved middleware functionality into decorator.