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
9use crate::dispatcher::StaticBackendDispatcher;
10
11/// Infrastructure context needed by the service layer: backend
12/// dispatcher, API endpoints, and TLS certificates.
13///
14/// Constructed per-request by `ServerState::infra_context(site_name)`
15/// from the matching `[sites.X]` block in `server.toml`. The borrows
16/// live for the duration of the handler call.
17#[derive(Debug)]
18pub struct InfraContext<'a> {
19 /// Backend client (CSM or OCHAMI) for this site.
20 pub backend: &'a StaticBackendDispatcher,
21 /// Name of the site this context belongs to, sourced from the
22 /// `X-Manta-Site` header on the inbound request.
23 pub site_name: &'a str,
24 /// Base URL of the site's CSM / OpenCHAMI API
25 /// (e.g. `https://api.alps.cscs.ch`).
26 pub shasta_base_url: &'a str,
27 /// DER- or PEM-encoded root CA bytes for verifying TLS against
28 /// `shasta_base_url`.
29 pub shasta_root_cert: &'a [u8],
30 /// Optional per-site SOCKS5 proxy URL forwarded to every outbound
31 /// HTTP request for this site's backend.
32 pub socks5_proxy: Option<&'a str>,
33 /// Optional Vault base URL; `None` makes Vault-dependent handlers
34 /// return 501.
35 pub vault_base_url: Option<&'a str>,
36 /// Base URL of the site's Gitea VCS, used by SAT-file rendering
37 /// and `run session` to resolve repository references.
38 pub gitea_base_url: &'a str,
39 /// Optional Kubernetes API URL; `None` makes k8s-dependent handlers
40 /// (console, session-logs SSE) return 501.
41 pub k8s_api_url: Option<&'a str>,
42}