Struct tonic_web::Config [−][src]
pub struct Config { /* fields omitted */ }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 theOPTIONSrequest 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-statusandgrpc-messagewill always be exposed.
Implementations
Allow any origin to access this resource.
This is the default value.
pub fn allow_origins<I>(self, origins: I) -> Config where
I: IntoIterator,
HeaderValue: TryFrom<I::Item>,
pub fn allow_origins<I>(self, origins: I) -> Config where
I: IntoIterator,
HeaderValue: TryFrom<I::Item>,
Only allow a specific set of origins to access this resource.
Example
tonic_web::config().allow_origins(vec!["http://a.com", "http://b.com"]);pub fn expose_headers<I>(self, headers: I) -> Config where
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
pub fn expose_headers<I>(self, headers: I) -> Config where
I: IntoIterator,
HeaderName: TryFrom<I::Item>,
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
Auto Trait Implementations
impl RefUnwindSafe for Config
impl UnwindSafe for Config
Blanket Implementations
Mutably borrows from an owned value. Read more
Wrap the input message T in a tonic::Request
pub fn vzip(self) -> V
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