manta_server/server/common/
app_context.rs

1//! Server-side runtime infrastructure context.
2//!
3//! `InfraContext` is the bundle of per-site connection data passed
4//! through the service layer for every request: backend dispatcher,
5//! API base URLs, TLS cert, optional vault/k8s URLs, SOCKS proxy.
6//! It depends on `StaticBackendDispatcher`, which is server-only —
7//! the CLI never instantiates this.
8//!
9//! `AppContext` is re-exported from `manta-shared` so handlers /
10//! services that want the CLI shape can keep using
11//! `crate::server::common::app_context::AppContext`.
12
13#[allow(unused_imports)]
14pub use manta_shared::common::app_context::AppContext;
15
16use crate::manta_backend_dispatcher::StaticBackendDispatcher;
17
18/// Infrastructure context needed by the service layer: backend
19/// dispatcher, API endpoints, and TLS certificates.
20///
21/// Constructed per-request by `ServerState::infra_context(site_name)`
22/// from the matching `[sites.X]` block in `server.toml`. The borrows
23/// live for the duration of the handler call.
24#[derive(Debug)]
25pub struct InfraContext<'a> {
26  /// Backend client (CSM or OCHAMI) for this site.
27  pub backend: &'a StaticBackendDispatcher,
28  /// Name of the site this context belongs to, sourced from the
29  /// `X-Manta-Site` header on the inbound request.
30  pub site_name: &'a str,
31  /// Base URL of the site's CSM / OpenCHAMI API
32  /// (e.g. `https://api.alps.cscs.ch`).
33  pub shasta_base_url: &'a str,
34  /// DER- or PEM-encoded root CA bytes for verifying TLS against
35  /// `shasta_base_url`.
36  pub shasta_root_cert: &'a [u8],
37  /// Optional per-site SOCKS5 proxy URL forwarded to every outbound
38  /// HTTP request for this site's backend.
39  pub socks5_proxy: Option<&'a str>,
40  /// Optional Vault base URL; `None` makes Vault-dependent handlers
41  /// return 501.
42  pub vault_base_url: Option<&'a str>,
43  /// Base URL of the site's Gitea VCS, used by SAT-file rendering
44  /// and `run session` to resolve repository references.
45  pub gitea_base_url: &'a str,
46  /// Optional Kubernetes API URL; `None` makes k8s-dependent handlers
47  /// (console, session-logs SSE) return 501.
48  pub k8s_api_url: Option<&'a str>,
49}