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//!
15//! The types are the core's own: this crate links `encore_sdk_core` directly, so
16//! there is nothing to marshal and no reason to define a parallel set.
17
18pub use encore_sdk_core::meta::{
19    AppMeta, BuildMeta, CloudProvider, DeployMeta, EnvironmentMeta, EnvironmentType, FrontendMeta,
20    GatewayMeta, HostedService,
21};
22
23/// Metadata about the running Encore application.
24///
25/// Computed once when the runtime is initialized (on first use of any Encore
26/// resource), so repeated calls are free.
27pub fn app_meta() -> &'static AppMeta {
28    crate::runtime::core().app_meta()
29}