pub struct WebAppConfig { /* private fields */ }Expand description
Application configuration
Implementations§
Source§impl WebAppConfig
impl WebAppConfig
Sourcepub fn with(name: &str, secure: bool, addr: SocketAddr, host: String) -> Self
pub fn with(name: &str, secure: bool, addr: SocketAddr, host: String) -> Self
Create an WebAppConfig instance.
Sourcepub fn name(&self) -> &ByteString
pub fn name(&self) -> &ByteString
Server name
Sourcepub fn host(&self) -> &str
pub fn host(&self) -> &str
Server host name
Host name is used by application router as a hostname for url generation.
Check ConnectionInfo::host()
documentation for more information.
By default host name is set to a “localhost:8080” value.
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
Returns the socket address of the local half of this TCP connection
Sourcepub fn forwarded(&self) -> &ForwardedPolicy
pub fn forwarded(&self) -> &ForwardedPolicy
Trust policy for the Forwarded and X-Forwarded-* request headers.
Sourcepub fn value<T: 'static>(&self) -> Option<&T>
pub fn value<T: 'static>(&self) -> Option<&T>
Get a configuration value stored with WebAppConfig::set_value().
Returns None if no value of type T is stored.
Sourcepub fn set_host(self, host: String) -> Self
pub fn set_host(self, host: String) -> Self
Set server host name.
By default host name is set to a “localhost:8080” value.
Sourcepub fn set_secure(self) -> Self
pub fn set_secure(self) -> Self
Connection is secure(https).
Sourcepub fn set_forwarded(self, policy: ForwardedPolicy) -> Self
pub fn set_forwarded(self, policy: ForwardedPolicy) -> Self
Set the trust policy for the Forwarded and X-Forwarded-* request
headers, used by ConnectionInfo.
By default the headers are ignored, see ForwardedPolicy.
Sourcepub fn set_local_addr(self, addr: SocketAddr) -> Self
pub fn set_local_addr(self, addr: SocketAddr) -> Self
Set the socket address of the local half of the TCP connection.
Sourcepub fn set_pool_size(self, size: usize) -> Self
pub fn set_pool_size(self, size: usize) -> Self
Set size of HttpRequest pool size.
By default pool size is 128.
Sourcepub fn set_value<T: Send + Sync + 'static>(self, val: T) -> Self
pub fn set_value<T: Send + Sync + 'static>(self, val: T) -> Self
Store a typed configuration value, replacing any value of the same type.
Values are available at runtime via HttpRequest::app_value().
Built-in extractors read their configuration, such as
JsonConfig,
FormConfig and
PayloadConfig, only from here.
This store is separate from the application state St
(for example AppState<T>) passed to handlers
registered with Route::to_with_state();
extractor configuration placed in the application state is ignored.