pub enum DefaultResponseType {
Json,
Html,
Auto,
}Expand description
默认响应类型策略(对齐 PHP autoResponse + 项目主策略扩展)
项目主策略为前后端分离,因此默认使用 Json。Auto 严格对齐 PHP TP 6
autoResponse() 的行为(根据 Accept 头判断)。Html 用于兜底场景
(如模板渲染、PDF/Excel 导出)。
Variants§
Json
项目主策略:默认返回 JSON(Content-Type: application/json; charset=utf-8)
控制器返回 Value(数组/对象)时,自动序列化为 JSON 响应。
不渲染模板,不检查 Accept 头。
Html
兜底场景:返回 HTML(Content-Type: text/html; charset=utf-8)
用于模板渲染、PDF/Excel 导出等非 JSON 场景。
Auto
对齐 PHP autoResponse:根据请求 Accept 头判断
- Accept 含
jsonMIME → JSON 响应 - Accept 不含
jsonMIME → HTML 响应(数组输出字面量 “Array”,对齐 PHP bug)
Implementations§
Trait Implementations§
Source§impl Clone for DefaultResponseType
impl Clone for DefaultResponseType
Source§fn clone(&self) -> DefaultResponseType
fn clone(&self) -> DefaultResponseType
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 DefaultResponseType
Source§impl Debug for DefaultResponseType
impl Debug for DefaultResponseType
Source§impl Default for DefaultResponseType
impl Default for DefaultResponseType
Source§fn default() -> DefaultResponseType
fn default() -> DefaultResponseType
Returns the “default value” for a type. Read more
impl Eq for DefaultResponseType
Source§impl PartialEq for DefaultResponseType
impl PartialEq for DefaultResponseType
impl StructuralPartialEq for DefaultResponseType
Auto Trait Implementations§
impl Freeze for DefaultResponseType
impl RefUnwindSafe for DefaultResponseType
impl Send for DefaultResponseType
impl Sync for DefaultResponseType
impl Unpin for DefaultResponseType
impl UnsafeUnpin for DefaultResponseType
impl UnwindSafe for DefaultResponseType
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.