Modify middleware behavior for taking a function that takes a response and returns a new response which will be stringify into JSON.