Skip to main content

WebAppConfig

Struct WebAppConfig 

Source
pub struct WebAppConfig { /* private fields */ }
Expand description

Application configuration

Implementations§

Source§

impl WebAppConfig

Source

pub fn new() -> Self

Create an default WebAppConfig instance.

Source

pub fn with(name: &str, secure: bool, addr: SocketAddr, host: String) -> Self

Create an WebAppConfig instance.

Source

pub fn name(&self) -> &ByteString

Server name

Source

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.

Source

pub fn secure(&self) -> bool

Returns true if connection is secure(https)

Source

pub fn local_addr(&self) -> SocketAddr

Returns the socket address of the local half of this TCP connection

Source

pub fn forwarded(&self) -> &ForwardedPolicy

Trust policy for the Forwarded and X-Forwarded-* request headers.

Source

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.

Source

pub fn set_host(self, host: String) -> Self

Set server host name.

By default host name is set to a “localhost:8080” value.

Source

pub fn set_secure(self) -> Self

Connection is secure(https).

Source

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.

Source

pub fn set_local_addr(self, addr: SocketAddr) -> Self

Set the socket address of the local half of the TCP connection.

Source

pub fn set_pool_size(self, size: usize) -> Self

Set size of HttpRequest pool size.

By default pool size is 128.

Source

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.

Trait Implementations§

Source§

impl Configuration for WebAppConfig

Source§

const NAME: &str = "Web app configuration"

Human-readable configuration name used in diagnostics.
Source§

fn ctx(&self) -> &CfgContext

Returns the shared context associated with this value.
Source§

fn set_ctx(&mut self, ctx: CfgContext)

Associates this value with a shared configuration context. Read more
Source§

impl Debug for WebAppConfig

Source§

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

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

impl Default for WebAppConfig

Source§

fn default() -> Self

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

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

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

§

fn vzip(self) -> V