pub struct RouterConfig {
pub auth_secret: String,
pub auth_enabled: bool,
pub cors_origins: Option<Vec<String>>,
pub cache_max_age: u32,
pub enable_tracing: bool,
}Expand description
Configuration for the HTTP router.
Fields§
§auth_secret: StringSecret key for signed URL authentication
auth_enabled: boolWhether authentication is enabled for tile requests
cors_origins: Option<Vec<String>>Allowed CORS origins (None = allow any origin)
cache_max_age: u32Cache-Control max-age in seconds
enable_tracing: boolWhether to enable request tracing
Implementations§
Source§impl RouterConfig
impl RouterConfig
Sourcepub fn new(auth_secret: impl Into<String>) -> Self
pub fn new(auth_secret: impl Into<String>) -> Self
Create a new router configuration with the given auth secret.
By default:
- Authentication is enabled
- CORS allows any origin
- Cache max-age is 1 hour (3600 seconds)
- Tracing is enabled
Sourcepub fn without_auth() -> Self
pub fn without_auth() -> Self
Create a configuration with authentication disabled.
Warning: This should only be used for development/testing.
Sourcepub fn with_cors_origins(self, origins: Vec<String>) -> Self
pub fn with_cors_origins(self, origins: Vec<String>) -> Self
Set specific allowed CORS origins.
Pass an empty vec to disallow all cross-origin requests. Pass None (or don’t call this method) to allow any origin.
Sourcepub fn with_cors_any_origin(self) -> Self
pub fn with_cors_any_origin(self) -> Self
Allow any CORS origin.
Sourcepub fn with_cache_max_age(self, seconds: u32) -> Self
pub fn with_cache_max_age(self, seconds: u32) -> Self
Set the Cache-Control max-age in seconds.
Sourcepub fn with_auth_enabled(self, enabled: bool) -> Self
pub fn with_auth_enabled(self, enabled: bool) -> Self
Enable or disable authentication.
Sourcepub fn with_tracing(self, enabled: bool) -> Self
pub fn with_tracing(self, enabled: bool) -> Self
Enable or disable request tracing.
Trait Implementations§
Source§impl Clone for RouterConfig
impl Clone for RouterConfig
Source§fn clone(&self) -> RouterConfig
fn clone(&self) -> RouterConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RouterConfig
impl RefUnwindSafe for RouterConfig
impl Send for RouterConfig
impl Sync for RouterConfig
impl Unpin for RouterConfig
impl UnwindSafe for RouterConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.