Skip to main content

ProviderHttpPolicy

Trait ProviderHttpPolicy 

Source
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§

Source

fn provider_id(&self) -> &'static str

Stable provider id (openrouter, openai, elevenlabs, xai).

Source

fn official_origins(&self) -> &'static [&'static str]

Official HTTPS origins (scheme + host, no path), e.g. https://openrouter.ai.

Source

fn default_base_url(&self) -> &'static str

Default base URL used when the caller omits an explicit endpoint.

Source

fn auth_scheme(&self) -> AuthScheme

Credential attachment scheme for this provider.

Source

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§

Source

fn apply_auth(&self, req: RequestBuilder, api_key: &str) -> RequestBuilder

Attach the API key using this policy’s auth scheme.

Source

fn apply_extra_headers(&self, req: RequestBuilder) -> RequestBuilder

Provider-specific headers (never cross-applied to other providers).

Source

fn is_official_origin(&self, scheme: &str, host: &str) -> bool

True when scheme/host match an official origin for this policy.

Source

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.

Source

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".

Implementors§