Skip to main content

WasmHttpContext

Struct WasmHttpContext 

Source
pub struct WasmHttpContext;
Expand description

WASM 侧的插件上下文实现。

不持有任何状态,所有数据通过宿主函数按需获取。

Trait Implementations§

Source§

impl PluginContext for WasmHttpContext

Source§

fn request_id(&self) -> String

请求 ID
Source§

fn request_ts(&self) -> i64

请求时间戳(毫秒)
Source§

fn is_sse(&self) -> bool

是否为 SSE 连接
Source§

fn is_websocket(&self) -> bool

是否为 WebSocket 连接
Source§

fn get_route_name(&self) -> Option<String>

路由名称
Source§

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

路由目标地址
Source§

fn get_response_body_size(&self) -> Option<i64>

响应体大小
Source§

fn set_response_body_size(&mut self, size: i64)

设置响应体大小
Source§

fn log(&self, level: i32, msg: &str)

输出日志(底层接口,level 使用 LOG_* 常量)
Source§

fn http_request(&self, req: &HttpRequest) -> Result<HttpResponse, PluginError>

发起 HTTP 请求(默认实现返回错误,WASM 侧通过宿主函数重写)
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

类型擦除,供宿主侧 downcast 获取 HttpContext
Source§

fn log_error(&self, msg: &str)

输出 ERROR 级别日志
Source§

fn log_warn(&self, msg: &str)

输出 WARN 级别日志
Source§

fn log_info(&self, msg: &str)

输出 INFO 级别日志
Source§

fn log_debug(&self, msg: &str)

输出 DEBUG 级别日志
Source§

fn log_trace(&self, msg: &str)

输出 TRACE 级别日志

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.