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: StringHost
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
impl RequestContext
pub fn get_request_ts(&self) -> i64
pub fn get_host(&self) -> &str
pub fn get_method(&self) -> Option<&str>
pub fn set_path(&self, path: &str)
pub fn get_path(&self) -> String
pub fn insert_header(&self, key: &str, value: &str)
pub fn get_header(&self, key: &str) -> Option<String>
pub fn remove_header(&self, key: &str)
pub fn insert_query(&self, name: &str, value: &str)
pub fn get_query(&self, name: &str) -> Option<String>
pub fn set_body(&self, body: Bytes)
pub fn get_body(&self) -> Option<&Bytes>
pub fn set_route(&self, route: Arc<Route>)
pub fn get_route(&self) -> Option<&Arc<Route>>
pub fn set_routing_url(&self, url: String)
pub fn get_routing_url(&self) -> Option<&String>
Trait Implementations§
Source§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 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