in callouts/python/extproc/example/add_custom_response/service_callout_example.py [0:0]
def on_response_body(self, body: service_pb2.HttpBody,
context: ServicerContext):
"""Custom processor on the response body.
Args:
body (service_pb2.BodyResponse): The HTTP body received in the response.
context (ServicerContext): The context object for the gRPC service.
Returns:
service_pb2.BodyResponse: The response containing the mutations to be applied
to the response body.
"""
if callout_tools.body_contains(body, "bad-body"):
callout_tools.deny_callout(context)
if callout_tools.body_contains(body, 'mock'):
return generate_mock_body_response()
return callout_tools.add_body_mutation()