From fd0d45b98ec1136aeb84fc28fa647df9023abf75 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Sat, 3 Oct 2026 20:25:37 +0300 Subject: 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. --- src/db.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index 28251d7..462639e 100644 --- a/src/db.rs +++ b/src/db.rs @@ -8,8 +8,7 @@ use serde::Serialize; /// SQL_URI config key GeneNetwork3 uses, so the two services can share /// configuration. fn sql_uri() -> String { - std::env::var("SQL_URI") - .unwrap_or_else(|_| "mysql://webqtlout:webqtlout@127.0.0.1/db_webqtl".to_string()) + crate::config::Config::load().sql_uri } #[derive(Serialize, utoipa::ToSchema)] -- cgit 1.4.1