Skip to main content

Outcome

Enum Outcome 

Source
pub enum Outcome {
    Continue,
    Respond(Response),
}
Expand description

插件控制流

插件阶段返回此枚举,决定网关是继续执行后续插件/流程,还是由插件主动响应并终止。

Variants§

§

Continue

继续执行下一个插件或后续流程

§

Respond(Response)

主动响应,会终止后续流程,当某个插件处理后,不想继续后续流程时,返回该值

Implementations§

Source§

impl Outcome

Source

pub fn goon() -> PluginResult

继续执行,等价于 Ok(Outcome::Continue)

Source

pub fn respond( status: u16, headers: Vec<(String, String)>, body: Vec<u8>, ) -> PluginResult

主动响应,会终止后续流程

Source

pub fn reject(status: u16, msg: impl Into<String>) -> PluginResult

拒绝请求,等价于 respond(status, vec![], msg)

用于限流(429)、鉴权失败(403)、参数校验(400) 等场景。

Source

pub fn execute_error(msg: impl Into<String>) -> PluginResult

Source

pub fn not_found(msg: impl Into<String>) -> PluginResult

Trait Implementations§

Source§

impl Debug for Outcome

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