A middleware for serializing data in the body of the response