pub struct BackendSection {
pub base_url: String,
pub auth: AuthConfig,
pub http: HttpConfig,
}Expand description
[backend] section — the OpenAPI/REST HTTP backend declaration (D-06).
This is the HTTP analog of DatabaseSection: it identifies the upstream
REST API the synthesized tools call. base_url is the API root; the optional
[backend.auth] sub-table selects an AuthConfig variant (type = "...")
and [backend.http] carries HttpConfig tuning (timeout / retries / …).
Gated behind the http feature — the whole section (and the
ServerConfig::backend field) is absent in a no-http build so there is no
dead stub type. AuthConfig and HttpConfig are DEFINED in
crate::http (Plan 90-01) and re-exported here, not redefined (H3).
Strict-parse discipline (D-13) is preserved: #[serde(deny_unknown_fields)]
rejects a typo’d key under [backend] or [backend.http].
Secrets posture (T-90-02-02): inline token fields under [backend.auth]
hold operator references (${ENV} / env:VAR) resolved upstream by the
Phase 83 secrets machinery — config parsing stores the string verbatim and
never the resolved value.
Fields§
§base_url: StringREST API root URL (e.g. "https://api.tfl.gov.uk"). Single-call tools
concatenate their path onto this (an empty per-tool base_url
inherits this value).
auth: AuthConfig[backend.auth] — outgoing authentication (AuthConfig, six modes).
Defaults to AuthConfig::None when the sub-table is omitted.
http: HttpConfig[backend.http] — client tuning (HttpConfig: timeout / retries /
backoff / user-agent / default headers). Defaults to HttpConfig’s
defaults when the sub-table is omitted.
Implementations§
Source§impl BackendSection
impl BackendSection
Sourcepub fn resolved_base_url(&self) -> Result<String, ToolkitError>
pub fn resolved_base_url(&self) -> Result<String, ToolkitError>
Resolve Self::base_url, expanding a ${VAR} / env:VAR reference
from the process environment. Callers MUST use this rather than reading
base_url directly — the raw field may hold an unresolved placeholder.
A Shape A server’s endpoint is frequently a slot the target environment
fills, so the config records base_url = "${TFL_BASE_URL}" and the
package digest stays environment-independent. Without expansion that
literal ${...} parses, VALIDATES (it is non-empty, so the emptiness
rule passes) and is then sent as the request URL.
Resolution rules — the grammar is crate::env_ref::parse_env_ref, the
single toolkit-wide chokepoint:
- a plain literal (no
${...}/env:prefix) is returned VERBATIM; ${VAR}/env:VARreadsVARfrom the process environment;- a MALFORMED reference — the empty
${}, or a multi-placeholder composition like${A}://${B}(a brace reference names exactly ONE variable) — is an error; - an UNSET variable, or one set to an empty / whitespace-only value, is an error.
§Deliberate divergence from credential resolution
A credential resolves an unset reference to the empty string so an
optional credential is OMITTED (see crate::http::auth). An endpoint
does NOT get that treatment: an empty credential yields a degraded
request, but an empty endpoint yields a broken one, and
ServerConfig::validate only checks emptiness at parse time — an
empty resolution would sail through and then break every request. This
uses the error-on-unset semantics of code_mode’s token_secret
resolution instead.
§Errors
Returns ToolkitError::UnresolvedBaseUrlRef when the reference cannot
be resolved. Per T-120-17 the error names the FIELD and the
environment-variable NAME only — never a resolved URL or credential.
§Examples
use pmcp_server_toolkit::config::ServerConfig;
let cfg = ServerConfig::from_toml_strict_validated(
"[server]\nname = \"demo\"\nversion = \"0.1.0\"\n\
[backend]\nbase_url = \"https://api.example.com\"\n",
)
.expect("valid config");
let backend = cfg.backend.as_ref().expect("[backend] present");
// A plain literal is used verbatim.
assert_eq!(backend.resolved_base_url().unwrap(), "https://api.example.com");Trait Implementations§
Source§impl Clone for BackendSection
impl Clone for BackendSection
Source§impl Debug for BackendSection
impl Debug for BackendSection
Source§impl Default for BackendSection
impl Default for BackendSection
Source§impl<'de> Deserialize<'de> for BackendSection
impl<'de> Deserialize<'de> for BackendSection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BackendSection
Source§impl PartialEq for BackendSection
impl PartialEq for BackendSection
Source§impl Serialize for BackendSection
impl Serialize for BackendSection
impl StructuralPartialEq for BackendSection
Auto Trait Implementations§
impl Freeze for BackendSection
impl RefUnwindSafe for BackendSection
impl Send for BackendSection
impl Sync for BackendSection
impl Unpin for BackendSection
impl UnsafeUnpin for BackendSection
impl UnwindSafe for BackendSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more