Skip to main content

encore/
env.rs

1//! Metadata about the running application — its environment, build, deployment,
2//! API gateways, and frontends.
3//!
4//! ```ignore
5//! let md = encore::env::app_meta();
6//! if md.environment.r#type == encore::env::EnvironmentType::Production {
7//!     // ...
8//! }
9//! // An app can declare several gateways, so look one up by name.
10//! if let Some(gw) = md.gateway("api") {
11//!     println!("api is at {}", gw.url);
12//! }
13//! ```
14
15pub use encore_sdk_core::meta::{
16    AppMeta, BuildMeta, CloudProvider, DeployMeta, EnvironmentMeta, EnvironmentType, FrontendMeta,
17    GatewayMeta, HostedService,
18};
19
20/// Returns metadata about the running Encore application.
21///
22/// This is computed once when the runtime initializes (on first use of any
23/// Encore resource), so repeated calls are inexpensive.
24pub fn app_meta() -> &'static AppMeta {
25    crate::runtime::core().app_meta()
26}