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<(ProxyRequest, Bytes), BrokerError>
pub fn post_json_exact( provider: impl Into<String>, path: impl Into<String>, body: Value, stream: bool, ) -> Result<(ProxyRequest, 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 moreSource§impl Debug for ProxyRequest
impl Debug for ProxyRequest
Source§impl<'de> Deserialize<'de> for ProxyRequest
impl<'de> Deserialize<'de> for ProxyRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ProxyRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ProxyRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ProxyRequest
impl Serialize for ProxyRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !Freeze for ProxyRequest
impl RefUnwindSafe for ProxyRequest
impl Send for ProxyRequest
impl Sync for ProxyRequest
impl Unpin for ProxyRequest
impl UnsafeUnpin for ProxyRequest
impl UnwindSafe for ProxyRequest
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
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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