Struct spacegate_kernel::plugins::context::SgRoutePluginContext
source · pub struct SgRoutePluginContext { /* private fields */ }Implementations§
source§impl SgRoutePluginContext
impl SgRoutePluginContext
pub fn new_http( method: Method, uri: Uri, version: Version, headers: HeaderMap<HeaderValue>, body: Body, remote_addr: SocketAddr, gateway_name: String, chose_route_rule: Option<ChoseHttpRouteRuleInst> ) -> Self
pub fn new_ws( method: Method, uri: Uri, version: Version, headers: HeaderMap<HeaderValue>, remote_addr: SocketAddr, gateway_name: String, chose_route_rule: Option<ChoseHttpRouteRuleInst> ) -> Self
sourcepub fn resp(
self,
status_code: StatusCode,
headers: HeaderMap<HeaderValue>,
body: Body
) -> Self
pub fn resp( self, status_code: StatusCode, headers: HeaderMap<HeaderValue>, body: Body ) -> Self
The following two methods can only be used to fill in the context [resp] [resp_from_error]
pub fn resp_from_error(self, error: TardisError) -> Self
pub fn get_request_id(&self) -> &str
pub fn get_request_kind(&self) -> &SgPluginFilterKind
pub fn is_resp_error(&self) -> bool
pub fn get_req_method(&mut self) -> &Method
pub fn set_req_method(&mut self, method: Method)
pub fn get_req_method_raw(&self) -> &Method
pub fn get_req_uri(&mut self) -> &Uri
pub fn set_req_uri(&mut self, uri: Uri)
pub fn get_req_uri_raw(&self) -> &Uri
pub fn get_req_version(&mut self) -> &Version
pub fn set_req_version(&mut self, version: Version)
pub fn get_req_version_raw(&self) -> &Version
pub fn get_req_headers(&mut self) -> &HeaderMap<HeaderValue>
pub fn get_req_headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
pub fn set_req_headers(&mut self, req_headers: HeaderMap<HeaderValue>)
pub fn set_req_header(&mut self, key: &str, value: &str) -> TardisResult<()>
pub fn get_req_headers_raw(&self) -> &HeaderMap<HeaderValue>
pub async fn pop_req_body(&mut self) -> TardisResult<Option<Vec<u8>>>
pub fn set_req_body(&mut self, body: Vec<u8>) -> TardisResult<()>
pub fn pop_req_body_raw(&mut self) -> TardisResult<Option<Body>>
pub fn get_req_remote_addr(&self) -> &SocketAddr
pub fn get_resp_status_code(&mut self) -> &StatusCode
pub fn set_resp_status_code(&mut self, status_code: StatusCode)
pub fn get_resp_status_code_raw(&self) -> &StatusCode
pub fn get_resp_headers(&mut self) -> &HeaderMap<HeaderValue>
pub fn get_resp_headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
pub fn set_resp_headers(&mut self, resp_headers: HeaderMap<HeaderValue>)
pub fn set_resp_header(&mut self, key: &str, value: &str) -> TardisResult<()>
pub fn remove_resp_header(&mut self, key: &str) -> TardisResult<()>
pub fn get_resp_headers_raw(&self) -> &HeaderMap<HeaderValue>
pub async fn pop_resp_body(&mut self) -> TardisResult<Option<Vec<u8>>>
sourcepub async fn build_response(&mut self) -> TardisResult<Response<Body>>
pub async fn build_response(&mut self) -> TardisResult<Response<Body>>
build response from Context
pub fn set_resp_body(&mut self, body: Vec<u8>) -> TardisResult<()>
pub fn pop_resp_body_raw(&mut self) -> TardisResult<Option<Body>>
pub fn get_ext(&self, key: &str) -> Option<String>
pub fn set_ext(&mut self, key: &str, value: &str)
pub fn remove_ext(&mut self, key: &str)
pub fn get_action(&self) -> &SgRouteFilterRequestAction
pub fn set_action(&mut self, action: SgRouteFilterRequestAction)
pub fn set_chose_backend(&mut self, chose_backend: &SgBackend)
pub fn get_chose_backend_name(&self) -> Option<String>
pub fn get_available_backend(&self) -> Vec<&AvailableBackendInst>
pub fn get_timeout_ms(&self) -> Option<u64>
pub fn get_rule_matched(&self) -> Option<SgHttpRouteMatchInst>
pub fn get_gateway_name(&self) -> String
pub fn cache(&self) -> TardisResult<&'static TardisCacheClient>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SgRoutePluginContext
impl Send for SgRoutePluginContext
impl Sync for SgRoutePluginContext
impl Unpin for SgRoutePluginContext
impl !UnwindSafe for SgRoutePluginContext
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