Skip to main content

RequestContext

Struct RequestContext 

Source
pub struct RequestContext {
    pub request_id: String,
    pub request_ts: i64,
    pub method: SV<String>,
    pub host: String,
    pub path: SV<String>,
    pub headers: DashMap<String, String>,
    pub query: DashMap<String, String>,
    pub body: SV<Bytes>,
    pub route: SV<Arc<Route>>,
    pub routing_url: SV<String>,
}
Expand description

请求上下文

Fields§

§request_id: String

请求ID

§request_ts: i64

收到请求的时间戳,毫秒

§method: SV<String>

请求方法:GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD

§host: String

Host

§path: SV<String>

请求路径,不含参数。

§headers: DashMap<String, String>

请求头

§query: DashMap<String, String>

请求的Query参数

§body: SV<Bytes>

请求体

§route: SV<Arc<Route>>

路由配置信息

§routing_url: SV<String>

路由目标地址,可以是域名或IP(包含协议头),由负载均衡器设置

Implementations§

Source§

impl RequestContext

Source

pub fn get_request_ts(&self) -> i64

Source

pub fn get_host(&self) -> &str

Source

pub fn get_method(&self) -> Option<&str>

Source

pub fn set_path(&self, path: &str)

Source

pub fn get_path(&self) -> String

Source

pub fn insert_header(&self, key: &str, value: &str)

Source

pub fn get_header(&self, key: &str) -> Option<String>

Source

pub fn remove_header(&self, key: &str)

Source

pub fn insert_query(&self, name: &str, value: &str)

Source

pub fn get_query(&self, name: &str) -> Option<String>

Source

pub fn set_body(&self, body: Bytes)

Source

pub fn get_body(&self) -> Option<&Bytes>

Source

pub fn set_route(&self, route: Arc<Route>)

Source

pub fn get_route(&self) -> Option<&Arc<Route>>

Source

pub fn set_routing_url(&self, url: String)

Source

pub fn get_routing_url(&self) -> Option<&String>

Trait Implementations§

Source§

impl Debug for RequestContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RequestContext

Source§

fn default() -> RequestContext

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.