pub trait ProviderHttpPolicy: Send + Sync {
// Required methods
fn provider_id(&self) -> &'static str;
fn official_origins(&self) -> &'static [&'static str];
fn default_base_url(&self) -> &'static str;
fn auth_scheme(&self) -> AuthScheme;
fn allows_path(&self, path: &str) -> bool;
// Provided methods
fn apply_auth(&self, req: RequestBuilder, api_key: &str) -> RequestBuilder { ... }
fn apply_extra_headers(&self, req: RequestBuilder) -> RequestBuilder { ... }
fn is_official_origin(&self, scheme: &str, host: &str) -> bool { ... }
fn allows_custom_credentialed_endpoint(&self) -> bool { ... }
fn custom_endpoint_hint(&self) -> String { ... }
}Expand description
Provider-specific HTTP trust and header contract.
Implementations must be pure reviewed code. Credentials may only be applied
after the transport has proven the final URL origin against this policy (or
an explicit custom-endpoint opt-in under crate::remote::RemotePolicy).
Required Methods§
Sourcefn provider_id(&self) -> &'static str
fn provider_id(&self) -> &'static str
Stable provider id (openrouter, openai, elevenlabs, xai).
Sourcefn official_origins(&self) -> &'static [&'static str]
fn official_origins(&self) -> &'static [&'static str]
Official HTTPS origins (scheme + host, no path), e.g. https://openrouter.ai.
Sourcefn default_base_url(&self) -> &'static str
fn default_base_url(&self) -> &'static str
Default base URL used when the caller omits an explicit endpoint.
Sourcefn auth_scheme(&self) -> AuthScheme
fn auth_scheme(&self) -> AuthScheme
Credential attachment scheme for this provider.
Sourcefn allows_path(&self, path: &str) -> bool
fn allows_path(&self, path: &str) -> bool
Whether path (relative to the validated base URL) is permitted.
Paths are normalized: leading / stripped; .., backslash, and NUL rejected.
Provided Methods§
Sourcefn apply_auth(&self, req: RequestBuilder, api_key: &str) -> RequestBuilder
fn apply_auth(&self, req: RequestBuilder, api_key: &str) -> RequestBuilder
Attach the API key using this policy’s auth scheme.
Sourcefn apply_extra_headers(&self, req: RequestBuilder) -> RequestBuilder
fn apply_extra_headers(&self, req: RequestBuilder) -> RequestBuilder
Provider-specific headers (never cross-applied to other providers).
Sourcefn is_official_origin(&self, scheme: &str, host: &str) -> bool
fn is_official_origin(&self, scheme: &str, host: &str) -> bool
True when scheme/host match an official origin for this policy.
Sourcefn allows_custom_credentialed_endpoint(&self) -> bool
fn allows_custom_credentialed_endpoint(&self) -> bool
Whether an explicit custom HTTPS endpoint may receive credentials when
crate::remote::RemotePolicy::allow_custom_credentialed_endpoint is set.
Sourcefn custom_endpoint_hint(&self) -> String
fn custom_endpoint_hint(&self) -> String
Operator-facing hint when a credentialed origin is rejected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".