pub struct AcceptFormat(pub ResponseFormat);Expand description
Extractor for response format preference from Accept header
JSON format requires a valid debug header (X-Debug-Format: <secret>).
If debug header is missing or invalid, Protobuf is returned even if
Accept header requests JSON.
§Example
ⓘ
async fn handler(format: AcceptFormat) -> ApiResponse<MyMessage> {
ApiResponse::ok(format.0, message)
}Tuple Fields§
§0: ResponseFormatTrait Implementations§
Source§impl<S> FromRequestParts<S> for AcceptFormat
impl<S> FromRequestParts<S> for AcceptFormat
Source§type Rejection = Infallible
type Rejection = Infallible
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Auto Trait Implementations§
impl Freeze for AcceptFormat
impl RefUnwindSafe for AcceptFormat
impl Send for AcceptFormat
impl Sync for AcceptFormat
impl Unpin for AcceptFormat
impl UnwindSafe for AcceptFormat
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
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.