Cloud Log

This module provides an example of Cloud Log.

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

Bases: CalloutServer

Example callout server.

For request header callouts we check the content of the request and authorize the request or reject the request. The content being checked is if the header has the header ‘header-check’. The decision is logged to Cloud Logging.

For request body callouts we check the content of the request and authorize the request or reject the request. The content being checked is if the body contains the body ‘body-check’. The decision is logged to Cloud Logging.

on_request_body(body: envoy.service.ext_proc.v3.external_processor_pb2.HttpBody, context: ServicerContext) envoy.service.ext_proc.v3.external_processor_pb2.BodyResponse[source]

Custom processor on the request body.

Parameters:
  • body (service_pb2.HttpBody) – The HTTP body received in the request.

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

Returns:

The response containing the mutations to be applied to the response body.

Return type:

service_pb2.BodyResponse

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

Custom processor on request headers.

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