Use the bang version of Phamtom to_pipe method in the middleware.