in callouts/python/extproc/example/update_header/service_callout_example.py [0:0]
def on_request_headers(
self, headers: service_pb2.HttpHeaders,
context: ServicerContext) -> service_pb2.HeadersResponse:
"""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.
"""
return callout_tools.add_header_mutation(
add=[('header-request', 'request-new-value')],
append_action=actions.OVERWRITE_IF_EXISTS_OR_ADD,
clear_route_cache=True)