diff options
| author | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-03 20:25:37 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-03 20:25:37 +0300 |
| commit | fd0d45b98ec1136aeb84fc28fa647df9023abf75 (patch) | |
| tree | 05748707d319deb9668a194a90c3724a69c4f328 /src/main.rs | |
| parent | 5ecc6b70e8a6ce2ba91f7808295a7d7672481d58 (diff) | |
| download | genenetwork4-fd0d45b98ec1136aeb84fc28fa647df9023abf75.tar.gz | |
Add foundation structure: config layering, response envelope, routes modules.
* src/config.rs: New module. Layered configuration, defaults -> GN4_CONF -> GN4_SECRETS -> environment, mirroring GeneNetwork3's SQL_URI convention so the two services can share configuration. Missing config files are ignored. * src/response.rs: New module. The descriptive success envelope (data + next actions) from the foundation design note (topics/gn4/gn4-api-foundation.gmi). Not yet adopted by existing endpoints; that is a deliberate wire-format change to agree on before it ships. * src/routes/mod.rs, species.rs, groups.rs: Move the species and groups handlers out of lib.rs into one module per domain, per the foundation structure. Handlers are pub; lib.rs just registers them. * src/lib.rs (app): Register the moved routes. hello_world and version predate the domain split and stay as top-level utility routes. * src/db.rs (sql_uri): Resolve through config::Config instead of reading the environment directly. * src/main.rs: Bind the port from config::Config.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 1b17f8e..58a96e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ #[tokio::main] async fn main() { - let port = std::env::var("GENENETWORK4_PORT").unwrap_or_else(|_| "3000".to_string()); - let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}")) + let config = genenetwork4::config::Config::load(); + let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", config.port)) .await .unwrap(); axum::serve(listener, genenetwork4::app()).await.unwrap(); |
