mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	feat: include version number in response headers and on application startup (#3045)
This commit is contained in:
		| @ -20,6 +20,9 @@ async fn main() -> DrainerResult<()> { | |||||||
|     let shutdown_intervals = conf.drainer.shutdown_interval; |     let shutdown_intervals = conf.drainer.shutdown_interval; | ||||||
|     let loop_interval = conf.drainer.loop_interval; |     let loop_interval = conf.drainer.loop_interval; | ||||||
|  |  | ||||||
|  |     #[cfg(feature = "vergen")] | ||||||
|  |     println!("Starting drainer (Version: {})", router_env::git_tag!()); | ||||||
|  |  | ||||||
|     let _guard = router_env::setup( |     let _guard = router_env::setup( | ||||||
|         &conf.log, |         &conf.log, | ||||||
|         router_env::service_name!(), |         router_env::service_name!(), | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ email = ["external_services/email", "dep:aws-config", "olap"] | |||||||
| frm = [] | frm = [] | ||||||
| basilisk = ["kms"] | basilisk = ["kms"] | ||||||
| stripe = ["dep:serde_qs"] | 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"] | olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "dep:analytics"] | ||||||
| oltp = ["storage_impl/oltp"] | oltp = ["storage_impl/oltp"] | ||||||
| kv_store = ["scheduler/kv_store"] | kv_store = ["scheduler/kv_store"] | ||||||
|  | |||||||
| @ -34,6 +34,9 @@ async fn main() -> ApplicationResult<()> { | |||||||
|     conf.validate() |     conf.validate() | ||||||
|         .expect("Failed to validate router configuration"); |         .expect("Failed to validate router configuration"); | ||||||
|  |  | ||||||
|  |     #[cfg(feature = "vergen")] | ||||||
|  |     println!("Starting router (Version: {})", router_env::git_tag!()); | ||||||
|  |  | ||||||
|     let _guard = router_env::setup( |     let _guard = router_env::setup( | ||||||
|         &conf.log, |         &conf.log, | ||||||
|         router_env::service_name!(), |         router_env::service_name!(), | ||||||
|  | |||||||
| @ -22,8 +22,6 @@ use tokio::sync::{mpsc, oneshot}; | |||||||
| const SCHEDULER_FLOW: &str = "SCHEDULER_FLOW"; | const SCHEDULER_FLOW: &str = "SCHEDULER_FLOW"; | ||||||
| #[tokio::main] | #[tokio::main] | ||||||
| async fn main() -> CustomResult<(), ProcessTrackerError> { | async fn main() -> CustomResult<(), ProcessTrackerError> { | ||||||
|     // console_subscriber::init(); |  | ||||||
|  |  | ||||||
|     let cmd_line = <CmdLineConf as clap::Parser>::parse(); |     let cmd_line = <CmdLineConf as clap::Parser>::parse(); | ||||||
|  |  | ||||||
|     #[allow(clippy::expect_used)] |     #[allow(clippy::expect_used)] | ||||||
| @ -58,6 +56,12 @@ async fn main() -> CustomResult<(), ProcessTrackerError> { | |||||||
|     let scheduler_flow = scheduler::SchedulerFlow::from_str(&scheduler_flow_str) |     let scheduler_flow = scheduler::SchedulerFlow::from_str(&scheduler_flow_str) | ||||||
|         .expect("Unable to parse SchedulerFlow from environment variable"); |         .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( |     let _guard = router_env::setup( | ||||||
|         &state.conf.log, |         &state.conf.log, | ||||||
|         &scheduler_flow_str, |         &scheduler_flow_str, | ||||||
|  | |||||||
| @ -70,7 +70,13 @@ where | |||||||
| pub fn default_response_headers() -> actix_web::middleware::DefaultHeaders { | pub fn default_response_headers() -> actix_web::middleware::DefaultHeaders { | ||||||
|     use actix_web::http::header; |     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. |         // Max age of 1 year in seconds, equal to `60 * 60 * 24 * 365` seconds. | ||||||
|         .add((header::STRICT_TRANSPORT_SECURITY, "max-age=31536000")) |         .add((header::STRICT_TRANSPORT_SECURITY, "max-age=31536000")) | ||||||
|         .add((header::VIA, "HyperSwitch")) |         .add((header::VIA, "HyperSwitch")) | ||||||
|  | |||||||
| @ -167,3 +167,13 @@ macro_rules! profile { | |||||||
|         env!("CARGO_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") | ||||||
|  |     }; | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Sanchith Hegde
					Sanchith Hegde