pub struct RequestContext {
pub headers: HashMap<String, String>,
pub username: Option<String>,
pub database: Option<String>,
pub auth_token: Option<String>,
pub sql_context: HashMap<String, String>,
pub client_ip: Option<String>,
pub connection_id: Option<u64>,
}Expand description
Request context for tenant identification
Fields§
§headers: HashMap<String, String>HTTP headers (or similar protocol headers)
username: Option<String>Username from authentication
database: Option<String>Database name from connection
auth_token: Option<String>Authentication token (e.g., JWT)
sql_context: HashMap<String, String>SQL context variables
client_ip: Option<String>Client IP address
connection_id: Option<u64>Connection ID
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Set a header
Sourcepub fn with_username(self, username: impl Into<String>) -> Self
pub fn with_username(self, username: impl Into<String>) -> Self
Set username
Sourcepub fn with_database(self, database: impl Into<String>) -> Self
pub fn with_database(self, database: impl Into<String>) -> Self
Set database
Sourcepub fn with_auth_token(self, token: impl Into<String>) -> Self
pub fn with_auth_token(self, token: impl Into<String>) -> Self
Set auth token
Sourcepub fn with_sql_context(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_sql_context( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Set SQL context variable
Sourcepub fn with_client_ip(self, ip: impl Into<String>) -> Self
pub fn with_client_ip(self, ip: impl Into<String>) -> Self
Set client IP
Sourcepub fn get_header(&self, name: &str) -> Option<&str>
pub fn get_header(&self, name: &str) -> Option<&str>
Get header value
Sourcepub fn get_sql_context(&self, name: &str) -> Option<&str>
pub fn get_sql_context(&self, name: &str) -> Option<&str>
Get SQL context variable
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RequestContext
impl Debug for RequestContext
Source§impl Default for RequestContext
impl Default for RequestContext
Source§fn default() -> RequestContext
fn default() -> RequestContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
impl UnwindSafe for RequestContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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