GrpcJsonTranscoder

Struct GrpcJsonTranscoder 

Source
pub struct GrpcJsonTranscoder {
Show 15 fields pub services: Vec<String>, pub print_options: Option<PrintOptions>, pub match_incoming_request_route: bool, pub ignored_query_parameters: Vec<String>, pub auto_mapping: bool, pub ignore_unknown_query_parameters: bool, pub convert_grpc_status: bool, pub url_unescape_spec: i32, pub query_param_unescape_plus: bool, pub match_unregistered_custom_verb: bool, pub request_validation_options: Option<RequestValidationOptions>, pub case_insensitive_enum_parsing: bool, pub max_request_body_size: Option<UInt32Value>, pub max_response_body_size: Option<UInt32Value>, pub descriptor_set: Option<DescriptorSet>,
}
Expand description

[#next-free-field: 17] GrpcJsonTranscoder filter configuration. The filter itself can be used per route / per virtual host or on the general level. The most specific one is being used for a given route. If the list of services is empty - filter is considered to be disabled. Note that if specifying the filter per route, first the route is matched, and then transcoding filter is applied. It matters when specifying the route configuration and paths to match the request - for per-route grpc transcoder configs, the original path should be matched, while in other cases, the grpc-like path is expected (the one AFTER the filter is applied).

Fields§

§services: Vec<String>

A list of strings that supplies the fully qualified service names (i.e. “package_name.service_name”) that the transcoder will translate. If the service name doesn’t exist in proto_descriptor, Envoy will fail at startup. The proto_descriptor may contain more services than the service names specified here, but they won’t be translated.

By default, the filter will pass through requests that do not map to any specified services. If the list of services is empty, filter is considered disabled. However, this behavior changes if :ref:reject_unknown_method <envoy_v3_api_field_extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder.RequestValidationOptions.reject_unknown_method> is enabled.

§print_options: Option<PrintOptions>

Control options for response JSON. These options are passed directly to JsonPrintOptions <<https://developers.google.com/protocol-buffers/docs/reference/cpp/> google.protobuf.util.json_util#JsonPrintOptions>_.

§match_incoming_request_route: bool

Whether to keep the incoming request route after the outgoing headers have been transformed to the match the upstream gRPC service. Note: This means that routes for gRPC services that are not transcoded cannot be used in combination with match_incoming_request_route.

§ignored_query_parameters: Vec<String>

A list of query parameters to be ignored for transcoding method mapping. By default, the transcoder filter will not transcode a request if there are any unknown/invalid query parameters.

Example :

.. code-block:: proto

 service Bookstore {
   rpc GetShelf(GetShelfRequest) returns (Shelf) {
     option (google.api.http) = {
       get: "/shelves/{shelf}"
     };
   }
 }

 message GetShelfRequest {
   int64 shelf = 1;
 }

 message Shelf {}

The request /shelves/100?foo=bar will not be mapped to GetShelf``` because variable binding for foois not defined. Addingfootoignored_query_parameterswill allow the same request to be mapped toGetShelf``.

§auto_mapping: bool

Whether to route methods without the google.api.http option.

Example :

.. code-block:: proto

 package bookstore;

 service Bookstore {
   rpc GetShelf(GetShelfRequest) returns (Shelf) {}
 }

 message GetShelfRequest {
   int64 shelf = 1;
 }

 message Shelf {}

The client could post a json body {"shelf": 1234} with the path of /bookstore.Bookstore/GetShelfRequest to call GetShelfRequest.

§ignore_unknown_query_parameters: bool

Whether to ignore query parameters that cannot be mapped to a corresponding protobuf field. Use this if you cannot control the query parameters and do not know them beforehand. Otherwise use ignored_query_parameters. Defaults to false.

§convert_grpc_status: bool

Whether to convert gRPC status headers to JSON. When trailer indicates a gRPC error and there was no HTTP body, take google.rpc.Status from the grpc-status-details-bin header and use it as JSON body. If there was no such header, make google.rpc.Status out of the grpc-status and grpc-message headers. The error details types must be present in the proto_descriptor.

For example, if an upstream server replies with headers:

.. code-block:: none

 grpc-status: 5
 grpc-status-details-bin:
     CAUaMwoqdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucnBjLlJlcXVlc3RJbmZvEgUKA3ItMQ

The grpc-status-details-bin header contains a base64-encoded protobuf message google.rpc.Status. It will be transcoded into:

.. code-block:: none

 HTTP/1.1 404 Not Found
 content-type: application/json

 {"code":5,"details":\[{"@type":"type.googleapis.com/google.rpc.RequestInfo","requestId":"r-1"}\]}

In order to transcode the message, the google.rpc.RequestInfo type from the google/rpc/error_details.proto should be included in the configured :ref:proto descriptor set <config_grpc_json_generate_proto_descriptor_set>.

§url_unescape_spec: i32

URL unescaping policy. This spec is only applied when extracting variable with multiple segments in the URL path. For example, in case of /foo/{x=*}/bar/{y=prefix/*}/{z=**} x variable is single segment and y and z are multiple segments. For a path with /foo/first/bar/prefix/second/third/fourth, x=first, y=prefix/second, z=third/fourth. If this setting is not specified, the value defaults to :ref:ALL_CHARACTERS_EXCEPT_RESERVED<envoy_v3_api_enum_value_extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder.UrlUnescapeSpec.ALL_CHARACTERS_EXCEPT_RESERVED>.

§query_param_unescape_plus: bool

If true, unescape ‘+’ to space when extracting variables in query parameters. This is to support HTML 2.0 <<https://tools.ietf.org/html/rfc1866#section-8.2.1>_>

§match_unregistered_custom_verb: bool

If true, try to match the custom verb even if it is unregistered. By default, only match when it is registered.

According to the http template syntax <<https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L226-L231>_,> the custom verb is “:” LITERAL at the end of http template.

For a request with /foo/bar:baz and :baz is not registered in any url_template, here is the behavior change

  • if the field is not set, :baz will not be treated as custom verb, so it will match /foo/{x=*}.
  • if the field is set, :baz is treated as custom verb, so it will NOT match /foo/{x=*} since the template doesn’t use any custom verb.
§request_validation_options: Option<RequestValidationOptions>

Configure the behavior when handling requests that cannot be transcoded.

By default, the transcoder will silently pass through HTTP requests that are malformed. This includes requests with unknown query parameters, unregister paths, etc.

Set these options to enable strict HTTP request validation, resulting in the transcoder rejecting such requests with a HTTP 4xx. See each individual option for more details on the validation. gRPC requests will still silently pass through without transcoding.

The benefit is a proper error message to the downstream. If the upstream is a gRPC server, it cannot handle the passed-through HTTP requests and will reset the TCP connection. The downstream will then receive a HTTP 503 Service Unavailable due to the upstream connection reset. This incorrect error message may conflict with other Envoy components, such as retry policies.

§case_insensitive_enum_parsing: bool

Proto enum values are supposed to be in upper cases when used in JSON. Set this to true if your JSON request uses non uppercase enum values.

§max_request_body_size: Option<UInt32Value>

The maximum size of a request body to be transcoded, in bytes. A body exceeding this size will provoke a HTTP 413 Request Entity Too Large response.

Large values may cause envoy to use a lot of memory if there are many concurrent requests.

If unset, the current stream buffer size is used.

§max_response_body_size: Option<UInt32Value>

The maximum size of a response body to be transcoded, in bytes. A body exceeding this size will provoke a HTTP 500 Internal Server Error response.

Large values may cause envoy to use a lot of memory if there are many concurrent requests.

If unset, the current stream buffer size is used.

§descriptor_set: Option<DescriptorSet>

Implementations§

Source§

impl GrpcJsonTranscoder

Source

pub fn url_unescape_spec(&self) -> UrlUnescapeSpec

Returns the enum value of url_unescape_spec, or the default if the field is set to an invalid enum value.

Source

pub fn set_url_unescape_spec(&mut self, value: UrlUnescapeSpec)

Sets url_unescape_spec to the provided enum value.

Trait Implementations§

Source§

impl Clone for GrpcJsonTranscoder

Source§

fn clone(&self) -> GrpcJsonTranscoder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GrpcJsonTranscoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GrpcJsonTranscoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for GrpcJsonTranscoder

§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Message for GrpcJsonTranscoder

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for GrpcJsonTranscoder

Source§

fn eq(&self, other: &GrpcJsonTranscoder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for GrpcJsonTranscoder

§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GrpcJsonTranscoder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,