pub enum Outcome {
Continue,
Respond(Response),
}Expand description
插件控制流
插件阶段返回此枚举,决定网关是继续执行后续插件/流程,还是由插件主动响应并终止。
Variants§
Implementations§
Source§impl Outcome
impl Outcome
Sourcepub fn goon() -> PluginResult
pub fn goon() -> PluginResult
继续执行,等价于 Ok(Outcome::Continue)
Sourcepub fn respond(
status: u16,
headers: Vec<(String, String)>,
body: Vec<u8>,
) -> PluginResult
pub fn respond( status: u16, headers: Vec<(String, String)>, body: Vec<u8>, ) -> PluginResult
主动响应,会终止后续流程
Sourcepub fn reject(status: u16, msg: impl Into<String>) -> PluginResult
pub fn reject(status: u16, msg: impl Into<String>) -> PluginResult
拒绝请求,等价于 respond(status, vec![], msg)
用于限流(429)、鉴权失败(403)、参数校验(400) 等场景。
pub fn execute_error(msg: impl Into<String>) -> PluginResult
pub fn not_found(msg: impl Into<String>) -> PluginResult
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Outcome
impl RefUnwindSafe for Outcome
impl Send for Outcome
impl Sync for Outcome
impl Unpin for Outcome
impl UnsafeUnpin for Outcome
impl UnwindSafe for Outcome
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