pub struct ServerConfig {
pub host: String,
pub port: u16,
pub domain: Vec<String>,
pub base_path: String,
pub workers: Option<usize>,
pub public_url: String,
}Fields§
§host: StringInterface to bind, e.g. 0.0.0.0. Empty or * means every interface
and is normalised to 0.0.0.0 on load.
port: u16TCP port.
domain: Vec<String>Only answer requests whose Host: header is one of these. Written as a
single string (domain = "api.example.com") or a list
(domain = ["api.example.com", "www.example.com"]). Unset — or the
catch-all spellings "", * and _ (nginx’s server_name _) —
answers any host, and all of them normalise to an empty list on load.
base_path: StringSub-path the API is mounted under, e.g. /api. Always starts with /
and never ends with one (normalised on load).
workers: Option<usize>Number of worker threads. None = one per CPU.
public_url: StringThe origin this server is reached at from outside — https://api.example.com.
Only links that leave the process need it: an invitation email has to
name a URL, and a request’s own Host: header is the wrong source for
one (a message is composed once and read anywhere, possibly behind a
proxy that rewrote it). Unset falls back to the first configured
domain, then to http://<host>:<port>, which is right for local
development and wrong in front of a load balancer — so set it there.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn public_origin(&self) -> String
pub fn public_origin(&self) -> String
The origin to put in a link that will be read outside this process.
Prefers what the app declared, then the first domain it answers for, and only then the socket it happens to be bound to.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more