pub struct ServerConfig {
pub bind_addr: SocketAddr,
pub request_timeout: Duration,
pub body_limit: usize,
pub cors_origins: Vec<String>,
pub auth: AuthConfig,
pub rate_limit: RateLimitConfig,
pub security_headers: bool,
}Expand description
Configuration for the HTTP server.
Fields§
§bind_addr: SocketAddrAddress to bind the server to. Default: 127.0.0.1:8080 (localhost only for security)
request_timeout: DurationRequest timeout. Default: 30 seconds
body_limit: usizeMaximum request body size in bytes. Default: 1MB
cors_origins: Vec<String>CORS allowed origins. Default: empty (CORS disabled)
auth: AuthConfigAPI key authentication configuration. Default: disabled (no keys configured)
rate_limit: RateLimitConfigRate limiting configuration. Default: 100 requests per minute per IP
security_headers: boolEnable security headers. Default: true
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn with_api_keys(self, keys: impl IntoIterator<Item = String>) -> Self
pub fn with_api_keys(self, keys: impl IntoIterator<Item = String>) -> Self
Create a config with API key authentication enabled.
Sourcepub fn without_rate_limit(self) -> Self
pub fn without_rate_limit(self) -> Self
Disable rate limiting.
Sourcepub fn with_rate_limit(self, max_requests: u32, window_secs: u64) -> Self
pub fn with_rate_limit(self, max_requests: u32, window_secs: u64) -> Self
Set custom rate limit.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServerConfig
impl Debug for ServerConfig
Auto Trait Implementations§
impl Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnwindSafe for ServerConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)