pub struct Config {
pub file_path: Option<String>,
pub listener: Option<ListenerConfig>,
pub log: Option<LogConfig>,
pub service: ServiceConfig,
}Expand description
Top-level application configuration, corresponding one-to-one with
apimock.toml.
Fields§
§file_path: Option<String>Where this config was loaded from. Kept so we can resolve relative paths (rule sets, middlewares, respond dirs) against the config file’s parent directory — not the process’s working directory.
listener: Option<ListenerConfig>§log: Option<LogConfig>§service: ServiceConfigImplementations§
Source§impl Config
impl Config
Sourcepub fn new(
config_file_path: Option<&String>,
fallback_respond_dir_path: Option<&String>,
) -> ConfigResult<Self>
pub fn new( config_file_path: Option<&String>, fallback_respond_dir_path: Option<&String>, ) -> ConfigResult<Self>
Build a Config by reading the TOML file, resolving rule-set
paths, and validating the result.
Middleware paths are recorded on the returned Config but not compiled here — the server crate performs compilation. See the module docstring for why.
Sourcepub fn compute_fallback_respond_dir(
&mut self,
fallback_respond_dir_path: Option<&String>,
) -> ConfigResult<()>
pub fn compute_fallback_respond_dir( &mut self, fallback_respond_dir_path: Option<&String>, ) -> ConfigResult<()>
Resolve the fallback respond dir against the config file’s parent directory. See the module doc for why we don’t resolve against CWD.
Sourcepub fn listener_http_addr(&self) -> Option<String>
pub fn listener_http_addr(&self) -> Option<String>
HTTP listener address, if HTTP is enabled.
Sourcepub fn listener_https_addr(&self) -> Option<String>
pub fn listener_https_addr(&self) -> Option<String>
HTTPS listener address, if TLS is configured.
Sourcepub fn current_dir_to_parent_dir_relative_path(&self) -> ConfigResult<String>
pub fn current_dir_to_parent_dir_relative_path(&self) -> ConfigResult<String>
Relative path from CWD to the parent dir of the config file.