pub struct CorsConfigBuilder { /* private fields */ }Expand description
Builder for constructing a valid CorsConfig.
Ensures that the unsafe credentialed-wildcard combination cannot be built. All origins must be explicitly provided; there is no default.
Implementations§
Source§impl CorsConfigBuilder
impl CorsConfigBuilder
Sourcepub fn allow_origin(self, origin: &str) -> Self
pub fn allow_origin(self, origin: &str) -> Self
Add an allowed origin (e.g., "https://example.com" or "*").
Can be called multiple times to add multiple origins.
Sourcepub fn allow_credentials(self, yes: bool) -> Self
pub fn allow_credentials(self, yes: bool) -> Self
Enable or disable credentialed requests (Authorization headers, cookies, etc.).
Defaults to false. If set to true and a wildcard origin is added,
build() will reject the configuration.
Sourcepub fn build(self) -> Result<CorsConfig, CorsConfigError>
pub fn build(self) -> Result<CorsConfig, CorsConfigError>
Build the CORS configuration, validating that credentials and wildcard are not both enabled.
Trait Implementations§
Source§impl Debug for CorsConfigBuilder
impl Debug for CorsConfigBuilder
Source§impl Default for CorsConfigBuilder
impl Default for CorsConfigBuilder
Source§fn default() -> CorsConfigBuilder
fn default() -> CorsConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CorsConfigBuilder
impl RefUnwindSafe for CorsConfigBuilder
impl Send for CorsConfigBuilder
impl Sync for CorsConfigBuilder
impl Unpin for CorsConfigBuilder
impl UnsafeUnpin for CorsConfigBuilder
impl UnwindSafe for CorsConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more