Added filter() method to intercept response before returning to the client.