in callouts/python/extproc/example/basic/service_callout_example.py [0:0]
def on_request_headers(self, headers: HttpHeaders, _) -> HeadersResponse:
"""Custom processor on request headers.
This example contains a few of the possible modifications that can be
applied to a request header callout:
* A change to the ':authority' and ':path' headers.
* Adding the header 'header-request' with the value of 'request'.
* Removal of a header 'foo'.
* Clearing of the route cache.
"""
logging.debug("Received request headers callout: %s", headers)
return add_header_mutation(
add=[
# Change the host to 'service-extensions.com'.
(':authority', 'service-extensions.com'),
# Change the destination path to '/'.
(':path', '/'),
('header-request', 'request')
],
remove=['foo'],
clear_route_cache=True)