Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat: include version number in response headers and on application startup (#3045)
Sanchith Hegde252443a50dc4
diff --git a/crates/drainer/src/main.rs b/crates/drainer/src/main.rsindex 2b4142abc0..9e8b8e275c 100644--- a/crates/drainer/src/main.rs+++ b/crates/drainer/src/main.rs@@ -20,6 +20,9 @@ async fn main() -> DrainerResult<()> {let shutdown_intervals = conf.drainer.shutdown_interval;let loop_interval = conf.drainer.loop_interval;+ #[cfg(feature = "vergen")]+ println!("Starting drainer (Version: {})", router_env::git_tag!());+let _guard = router_env::setup(&conf.log,router_env::service_name!(),diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.tomlindex a1ddc37bbf..eb7fbc7ddb 100644--- a/crates/router/Cargo.toml+++ b/crates/router/Cargo.toml@@ -16,7 +16,7 @@ email = ["external_services/email", "dep:aws-config", "olap"]frm = []basilisk = ["kms"]stripe = ["dep:serde_qs"]-release = ["kms", "stripe", "basilisk", "s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing"]+release = ["kms", "stripe", "basilisk", "s3", "email", "backwards_compatibility", "business_profile_routing", "accounts_cache", "kv_store", "connector_choice_mca_id", "profile_specific_fallback_routing", "vergen"]olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "dep:analytics"]oltp = ["storage_impl/oltp"]kv_store = ["scheduler/kv_store"]diff --git a/crates/router/src/bin/router.rs b/crates/router/src/bin/router.rsindex beb2869f99..a02758d8ed 100644--- a/crates/router/src/bin/router.rs+++ b/crates/router/src/bin/router.rs@@ -34,6 +34,9 @@ async fn main() -> ApplicationResult<()> {conf.validate().expect("Failed to validate router configuration");+ #[cfg(feature = "vergen")]+ println!("Starting router (Version: {})", router_env::git_tag!());+let _guard = router_env::setup(&conf.log,router_env::service_name!(),diff --git a/crates/router/src/bin/scheduler.rs b/crates/router/src/bin/scheduler.rsindex 32e9cfc6ca..b800ecb897 100644--- a/crates/router/src/bin/scheduler.rs+++ b/crates/router/src/bin/scheduler.rs@@ -22,8 +22,6 @@ use tokio::sync::{mpsc, oneshot};const SCHEDULER_FLOW: &str = "SCHEDULER_FLOW";#[tokio::main]async fn main() -> CustomResult<(), ProcessTrackerError> {- // console_subscriber::init();-let cmd_line = <CmdLineConf as clap::Parser>::parse();#[allow(clippy::expect_used)]@@ -58,6 +56,12 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {let scheduler_flow = scheduler::SchedulerFlow::from_str(&scheduler_flow_str).expect("Unable to parse SchedulerFlow from environment variable");+ #[cfg(feature = "vergen")]+ println!(+ "Starting {scheduler_flow} (Version: {})",+ router_env::git_tag!()+ );+let _guard = router_env::setup(&state.conf.log,&scheduler_flow_str,diff --git a/crates/router/src/middleware.rs b/crates/router/src/middleware.rsindex 0f2c5bd2cb..c6c94d3a78 100644--- a/crates/router/src/middleware.rs+++ b/crates/router/src/middleware.rs@@ -70,7 +70,13 @@ wherepub fn default_response_headers() -> actix_web::middleware::DefaultHeaders {use actix_web::http::header;- actix_web::middleware::DefaultHeaders::new()+ let default_headers_middleware = actix_web::middleware::DefaultHeaders::new();++ #[cfg(feature = "vergen")]+ let default_headers_middleware =+ default_headers_middleware.add(("x-hyperswitch-version", router_env::git_tag!()));++ default_headers_middleware// Max age of 1 year in seconds, equal to `60 * 60 * 24 * 365` seconds..add((header::STRICT_TRANSPORT_SECURITY, "max-age=31536000")).add((header::VIA, "HyperSwitch"))diff --git a/crates/router_env/src/env.rs b/crates/router_env/src/env.rsindex e57c38e7e4..644f9b50a1 100644--- a/crates/router_env/src/env.rs+++ b/crates/router_env/src/env.rs@@ -167,3 +167,13 @@ macro_rules! profile {env!("CARGO_PROFILE")};}++/// The latest git tag. If tags are not present in the repository, the short commit hash is used+/// instead. Refer to the [`git describe`](https://git-scm.com/docs/git-describe) documentation for+/// more details.+#[macro_export]+macro_rules! git_tag {+ () => {+ env!("VERGEN_GIT_DESCRIBE")+ };+}