An application's configuration: a JSON file, then ORBIT_* environment variables, then command-line flags (later wins).
The "server" section becomes a ServerConfig; its keys are the ServerConfig field names, with durations in seconds and the engine ("epoll", "iouring", "auto") and HTTP version ("1.1", "2", "3") as strings. Every other section is the application's, read with section().
{
"server": { "port": 8080, "worker_threads": "auto", "header_timeout": 5 },
"database": { "url": "postgres://localhost/app", "pool_size": 8 }
}
auto db_url = cfg.section("database").value("url", "");
static Config load(const std::string &path, int argc=0, char *argv[]=nullptr, ServerConfig::ParseMode mode=ServerConfig::ParseMode::Lenient)
Reads path, applies the environment, then the command line (as ServerConfig::parse(); pass argc = 0 f...
The main application class for the Orbit Framework.
Definition App.hpp:36
Environment variables:
ORBIT_<KEY> sets server.<key> for a key the server section knows (ORBIT_PORT=9000, ORBIT_LOG_LEVEL=DEBUG); others are ignored.
ORBIT_<SECTION>__<KEY> (double underscore between levels) sets any path (ORBIT_DATABASE__URL=..., ORBIT_SERVER__PORT=9000). Names are matched case-insensitively. A value that parses as JSON (a number, true/false, an array) is used as such, anything else as a string.
Validation is strict: an unknown key in the server section, or a value of the wrong type or out of range, throws ConfigError naming the key.