pub struct Config { /* private fields */ }
Expand description

A Configuration builder for grpc_web services.

Config can be used to tweak the behavior of tonic_web services. Currently, Config instances only expose cors settings. However, since tonic_web is designed to work with grpc-web compliant clients only, some cors options have specific default values and not all settings are configurable.

Default values and configuration options

  • allow-origin: All origins allowed by default. Configurable, but null and wildcard origins are not supported.
  • allow-methods: [POST,OPTIONS]. Not configurable.
  • allow-headers: Set to whatever the OPTIONS request carries. Not configurable.
  • allow-credentials: true. Configurable.
  • max-age: 86400. Configurable.
  • expose-headers: grpc-status,grpc-message. Configurable but values can only be added. grpc-status and grpc-message will always be exposed.

Implementations

Allow any origin to access this resource.

This is the default value.

Only allow a specific set of origins to access this resource.

Example
tonic_web::config().allow_origins(vec!["http://a.com", "http://b.com"]);

Adds multiple headers to the list of exposed headers.

Default: grpc-status,grpc-message. These will always be included.

Defines the maximum cache lifetime for operations allowed on this resource.

Default: “86400” (24 hours)

If true, the access-control-allow-credentials will be sent.

Default: true

enable a tonic service to handle grpc-web requests with this configuration values.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Wrap the input message T in a tonic::Request

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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