pub struct ProxyRequest {
pub provider: String,
pub method: ProxyMethod,
pub path: String,
pub body: Option<Value>,
pub stream: bool,
pub body_bytes: Option<Bytes>,
}Expand description
A typed, credential-free request the broker executes on the caller’s behalf against an OpenAI-compatible provider endpoint.
The caller names a provider and a relative path; the broker derives the destination from its pinned provider table and applies the (broker-owned) credential. Callers can never supply an absolute URL for a static-key provider, so a key can never be coaxed toward an attacker-chosen host.
Fields§
§provider: StringStatic provider key (e.g. groq) or local.
method: ProxyMethod§path: StringRelative path joined onto the pinned base URL, e.g. /chat/completions.
body: Option<Value>JSON request body (POST only).
stream: boolRequest an SSE byte stream (proxy_stream) instead of a buffered body.
body_bytes: Option<Bytes>Typed exact-byte handoff (request-trace spec §6.2): when present this
MUST be the exact serialization of body, produced once by the
caller. LocalBroker sends these very bytes upstream verbatim, so
a caller-computed digest over them is a digest of the true wire body.
The field never crosses the remote broker HTTP boundary
(serde(skip)): a remote broker daemon re-serializes body on its
side, so callers on a remote path must NOT claim exact upstream
bytes. Never logged, never part of the broker wire schema.
Implementations§
Source§impl ProxyRequest
impl ProxyRequest
Sourcepub fn validate(&self) -> Result<(), BrokerError>
pub fn validate(&self) -> Result<(), BrokerError>
Validate provider identity and path shape. Fail closed on anything that could redirect a broker-owned credential.
Sourcepub fn post_json_exact(
provider: impl Into<String>,
path: impl Into<String>,
body: Value,
stream: bool,
) -> Result<(Self, Bytes), BrokerError>
pub fn post_json_exact( provider: impl Into<String>, path: impl Into<String>, body: Value, stream: bool, ) -> Result<(Self, Bytes), BrokerError>
Build a POST proxy request whose JSON body is serialized exactly
once: the returned bytes::Bytes handle shares the same buffer
stored in body_bytes (ref-counted clone, no copy), so a
caller-side digest over it is a digest of the true wire body on the
local-broker path. This is the sanctioned way to populate
body_bytes — going through it makes a body/body_bytes
semantic divergence unconstructible, and it never re-serializes on
the release hot path.
Trait Implementations§
Source§impl Clone for ProxyRequest
impl Clone for ProxyRequest
Source§fn clone(&self) -> ProxyRequest
fn clone(&self) -> ProxyRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more