in callouts/python/extproc/example/add_custom_response/service_callout_example.py [0:0]
def on_request_headers(
self, headers: service_pb2.HttpHeaders,
context: ServicerContext):
"""Custom processor on request headers.
Args:
headers (service_pb2.HttpHeaders): The HTTP headers received in the request.
context (ServicerContext): The context object for the gRPC service.
Returns:
service_pb2.HeadersResponse: The response containing the mutations to be applied
to the request headers.
"""
if callout_tools.headers_contain(headers, "bad-header"):
callout_tools.deny_callout(context)
if callout_tools.headers_contain(headers, "mock"):
return generate_mock_header_response()
return callout_tools.add_header_mutation(add=[('header-request', 'request')
],
remove=['foo'],
clear_route_cache=True)