pub enum MiddlewareKind {
Trace,
Cors,
Log,
RateLimit,
Auth,
}Expand description
中间件类型枚举
对齐 PHP 中间件 + sz-rust 自定义中间件。每个变体对应一个具体的 Layer 实现,
由 auth.rs / log.rs / cors.rs / rate_limit.rs 等模块逐个实现。
Variants§
Trace
追踪 span(生成 request_id,对齐 PHP SessionInit 的「请求初始化」语义)
最先执行:包裹所有后续中间件,确保 request_id 在所有日志/追踪中可用。
Cors
CORS 跨域预处理(对齐 PHP AllowCrossDomain)
第二执行:OPTIONS 预检请求直接返回,不进入业务逻辑。
Log
请求/响应日志(对齐 PHP think-logger)
第三执行:在限流/鉴权之前记录所有请求(包括被拒绝的)。
RateLimit
限流(复用 sz-orm-limit)
第四执行:在鉴权之前限流,避免无效请求消耗鉴权开销。
Auth
JWT 鉴权(对齐 PHP app\<app>\middleware\Auth,复用 sz-orm-auth)
第五执行:通过限流后进行鉴权,未登录返回 NotLogin(-1)。
Implementations§
Trait Implementations§
Source§impl Clone for MiddlewareKind
impl Clone for MiddlewareKind
Source§fn clone(&self) -> MiddlewareKind
fn clone(&self) -> MiddlewareKind
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MiddlewareKind
Source§impl Debug for MiddlewareKind
impl Debug for MiddlewareKind
Source§impl Display for MiddlewareKind
impl Display for MiddlewareKind
impl Eq for MiddlewareKind
Source§impl Hash for MiddlewareKind
impl Hash for MiddlewareKind
Source§impl PartialEq for MiddlewareKind
impl PartialEq for MiddlewareKind
impl StructuralPartialEq for MiddlewareKind
Auto Trait Implementations§
impl Freeze for MiddlewareKind
impl RefUnwindSafe for MiddlewareKind
impl Send for MiddlewareKind
impl Sync for MiddlewareKind
impl Unpin for MiddlewareKind
impl UnsafeUnpin for MiddlewareKind
impl UnwindSafe for MiddlewareKind
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.