Skip to main content

gproxy_channel_api/
context.rs

1//! Input contexts passed to channel hooks.
2
3use bytes::Bytes;
4use http::{HeaderMap, StatusCode};
5use serde_json::Value;
6
7/// Declared upstream transport, retained for compatibility with existing
8/// channel implementations.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum TransportKind {
11    Http,
12    Ws,
13}
14
15/// Per-call inputs used to build an upstream request.
16pub struct PrepareCtx<'a> {
17    pub secret: &'a Value,
18    pub provider_settings: &'a Value,
19    pub op: crate::protocol::OperationKey,
20    pub stream: bool,
21    pub upstream_model_id: &'a str,
22    pub method: http::Method,
23    pub path: &'a str,
24    pub query: Option<&'a str>,
25    pub headers: &'a HeaderMap,
26    pub body: Bytes,
27}
28
29/// Operation and settings available to request/response shaping hooks.
30#[derive(Debug, Clone, Copy)]
31pub struct ShapeCtx<'a> {
32    pub op: crate::protocol::OperationKey,
33    pub stream: bool,
34    pub status: StatusCode,
35    pub settings: &'a Value,
36}
37
38/// Inputs for a host-orchestrated credential refresh.
39#[derive(Debug, Clone, Copy)]
40pub struct RefreshCtx<'a> {
41    pub secret: &'a Value,
42    pub provider_settings: &'a Value,
43}