Redirect

This module provides an example of for a given URL, redirect to another URL.

class callouts.python.extproc.example.redirect.service_callout_example.CalloutServerExample(*args: Any, **kwargs: Any)[source]

Bases: CalloutServer

Example redirect callout server.

This class implements the CalloutServer interface and provides sample responses for various callout interactions. It showcases how to modify request headers using an immediate response.

On a request header callout we perform a redirect to ‘{http://service-extensions.com/redirect}’ with the status of ‘{301}’ - MovedPermanently returning an ImmediateResponse

on_request_headers(headers: envoy.service.ext_proc.v3.external_processor_pb2.HttpHeaders, context: ServicerContext) envoy.service.ext_proc.v3.external_processor_pb2.ImmediateResponse[source]

Custom processor on request headers.

This method is invoked when Envoy sends the request headers for processing. Here, we modify the headers to perform a 301 redirect.

Parameters:
  • headers (service_pb2.HttpHeaders) – The HTTP headers received in the request.

  • context (ServicerContext) – The context object for the gRPC service.

Returns:

The response containing the mutations to be applied to the request headers.

Return type:

service_pb2.HeadersResponse