pub struct AppState { /* private fields */ }Expand description
State shared across all axum handlers.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(client: Client) -> Self
pub fn new(client: Client) -> Self
Build app state from a configured bezant::Client.
Debug endpoints are disabled by default. Use
AppState::with_debug_token to enable them with token gating.
Events are disabled by default. Use AppState::with_events to
attach a connector handle.
Sourcepub fn with_debug_token(client: Client, token: impl Into<String>) -> Self
pub fn with_debug_token(client: Client, token: impl Into<String>) -> Self
Enable the /debug/* endpoints, requiring the given token on
every request (via ?token=… or X-Bezant-Debug-Token header).
Without this, all /debug/* routes 404.
Security: the cookie jar holds live IBKR session cookies
— anyone who can read it can resume the IBKR session and
trade the account. Pick a long, random token (>=32 bytes
from /dev/urandom) and treat it like a credential.
Sourcepub fn with_events(self, events: EventsHandle) -> Self
pub fn with_events(self, events: EventsHandle) -> Self
Return a new state with the given events handle attached. The
handle is what powers /events/* reads. Without it, those routes
return 503.
Sourcepub fn record_sso_bridge(&self, status: u16)
pub fn record_sso_bridge(&self, status: u16)
Record what the SSO bridge just answered. Called from the proxy as
ssodh/init responses pass through — see SsoBridge.
A poisoned lock is recovered from rather than propagated: this is observability, and it must never be the reason a proxied trading call fails.
Sourcepub fn sso_bridge(&self) -> Option<SsoBridge>
pub fn sso_bridge(&self) -> Option<SsoBridge>
The last observed SSO bridge state, if any call has been seen.
Sourcepub fn debug_token(&self) -> Option<&str>
pub fn debug_token(&self) -> Option<&str>
Borrow the configured debug token, if any.
Sourcepub fn events(&self) -> Option<&EventsHandle>
pub fn events(&self) -> Option<&EventsHandle>
Borrow the events handle, if attached.