pub struct SgRoutePluginContext { /* private fields */ }

Implementations§

source§

impl SgRoutePluginContext

source

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

source

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

source

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]

source

pub fn resp_from_error(self, error: TardisError) -> Self

source

pub fn get_request_id(&self) -> &str

source

pub fn get_request_kind(&self) -> &SgPluginFilterKind

source

pub fn is_resp_error(&self) -> bool

source

pub fn get_req_method(&mut self) -> &Method

source

pub fn set_req_method(&mut self, method: Method)

source

pub fn get_req_method_raw(&self) -> &Method

source

pub fn get_req_uri(&mut self) -> &Uri

source

pub fn set_req_uri(&mut self, uri: Uri)

source

pub fn get_req_uri_raw(&self) -> &Uri

source

pub fn get_req_version(&mut self) -> &Version

source

pub fn set_req_version(&mut self, version: Version)

source

pub fn get_req_version_raw(&self) -> &Version

source

pub fn get_req_headers(&mut self) -> &HeaderMap<HeaderValue>

source

pub fn get_req_headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>

source

pub fn set_req_headers(&mut self, req_headers: HeaderMap<HeaderValue>)

source

pub fn set_req_header(&mut self, key: &str, value: &str) -> TardisResult<()>

source

pub fn get_req_headers_raw(&self) -> &HeaderMap<HeaderValue>

source

pub async fn pop_req_body(&mut self) -> TardisResult<Option<Vec<u8>>>

source

pub fn set_req_body(&mut self, body: Vec<u8>) -> TardisResult<()>

source

pub fn pop_req_body_raw(&mut self) -> TardisResult<Option<Body>>

source

pub fn get_req_remote_addr(&self) -> &SocketAddr

source

pub fn get_resp_status_code(&mut self) -> &StatusCode

source

pub fn set_resp_status_code(&mut self, status_code: StatusCode)

source

pub fn get_resp_status_code_raw(&self) -> &StatusCode

source

pub fn get_resp_headers(&mut self) -> &HeaderMap<HeaderValue>

source

pub fn get_resp_headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>

source

pub fn set_resp_headers(&mut self, resp_headers: HeaderMap<HeaderValue>)

source

pub fn set_resp_header(&mut self, key: &str, value: &str) -> TardisResult<()>

source

pub fn remove_resp_header(&mut self, key: &str) -> TardisResult<()>

source

pub fn get_resp_headers_raw(&self) -> &HeaderMap<HeaderValue>

source

pub async fn pop_resp_body(&mut self) -> TardisResult<Option<Vec<u8>>>

source

pub async fn build_response(&mut self) -> TardisResult<Response<Body>>

build response from Context

source

pub fn set_resp_body(&mut self, body: Vec<u8>) -> TardisResult<()>

source

pub fn pop_resp_body_raw(&mut self) -> TardisResult<Option<Body>>

source

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

source

pub fn set_ext(&mut self, key: &str, value: &str)

source

pub fn remove_ext(&mut self, key: &str)

source

pub fn get_action(&self) -> &SgRouteFilterRequestAction

source

pub fn set_action(&mut self, action: SgRouteFilterRequestAction)

source

pub fn set_chose_backend(&mut self, chose_backend: &SgBackend)

source

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

source

pub fn get_available_backend(&self) -> Vec<&AvailableBackendInst>

source

pub fn get_timeout_ms(&self) -> Option<u64>

source

pub fn get_rule_matched(&self) -> Option<SgHttpRouteMatchInst>

source

pub fn get_gateway_name(&self) -> String

source

pub fn cache(&self) -> TardisResult<&'static TardisCacheClient>

Trait Implementations§

source§

impl Debug for SgRoutePluginContext

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more