pub struct RestAdapter;Expand description
v1.4.106 D1 5a: REST surface adapter — 把 pipeline AuthDecision::Reject
翻成 axum Response.
历史: v1.4.104 阶段 5 把“翻 reject 为 HTTP response“作 free fn
reject_to_http_response 写在本文件; v1.4.106 D1 把 4 surface 的同类
translate fn 收敛到 [futu_auth_pipeline::SurfaceAdapter] trait, 让 4
surface 一致, 防 sibling-route 不一致 regression (codex round 3 F1 教训).
HTTP body 泛化策略 (v1.4.102 BUG-011 fix):
- 401: 保留 reason (让 client 知道 missing token / invalid bearer 类提示)
- 加
WWW-Authenticate: Bearerheader (RFC 7235 §3.1)
- 加
- 403 / 500: body 泛化 (不泄 key_id / scope / 内部 bug 信息), audit log 已含细节
- 429: 保留 reason (client 需 backoff 决策)
- 404: 保留 reason (REST 专属, unknown route 用)
Trait Implementations§
Source§impl SurfaceAdapter for RestAdapter
impl SurfaceAdapter for RestAdapter
Source§type WireResponse = Response<Body>
type WireResponse = Response<Body>
该 surface 的 wire-format response 类型. Read more
Source§fn surface_id() -> SurfaceId
fn surface_id() -> SurfaceId
surface id, 给 audit / metrics 用.
Source§fn translate_reject(kind: RejectKind, reason: String) -> Self::WireResponse
fn translate_reject(kind: RejectKind, reason: String) -> Self::WireResponse
把 [
RejectKind] + reason 翻成本 surface 的 wire-format error. Read more§fn translate_decision(decision: AuthDecision) -> Option<Self::WireResponse>
fn translate_decision(decision: AuthDecision) -> Option<Self::WireResponse>
便捷适配: 直接传 [
AuthDecision], 若 Allow 则返 None, Reject 则返
Some(wire_response). caller ? short-circuit 用. Read moreAuto Trait Implementations§
impl Freeze for RestAdapter
impl RefUnwindSafe for RestAdapter
impl Send for RestAdapter
impl Sync for RestAdapter
impl Unpin for RestAdapter
impl UnsafeUnpin for RestAdapter
impl UnwindSafe for RestAdapter
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