pub struct ResponseMutations {
pub headers: Vec<(String, Vec<u8>)>,
pub cookies: Vec<Cookie>,
pub delete_cookies: Vec<String>,
}Expand description
Mutable response container for setting response headers and cookies.
This extractor allows handlers to set additional response headers and cookies
that will be merged into the final response. The handler’s return value
determines the status code and body; ResponseMut adds headers on top.
§Example
ⓘ
use fastapi_core::extract::ResponseMut;
use fastapi_core::response::Json;
async fn handler(mut resp: ResponseMut) -> Json<Data> {
resp.header("X-Custom-Header", "custom-value");
resp.cookie("session", "abc123");
Json(data)
}Fields§
§headers: Vec<(String, Vec<u8>)>Headers to add to the response.
Cookies to set (name, value, attributes).
Cookies to delete.
Implementations§
Trait Implementations§
Source§impl Clone for ResponseMutations
impl Clone for ResponseMutations
Source§fn clone(&self) -> ResponseMutations
fn clone(&self) -> ResponseMutations
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResponseMutations
impl Debug for ResponseMutations
Source§impl Default for ResponseMutations
impl Default for ResponseMutations
Source§fn default() -> ResponseMutations
fn default() -> ResponseMutations
Returns the “default value” for a type. Read more
Source§impl FromRequest for ResponseMutations
impl FromRequest for ResponseMutations
Source§type Error = Infallible
type Error = Infallible
Error type when extraction fails.
Source§async fn from_request(
_ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( _ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl Freeze for ResponseMutations
impl RefUnwindSafe for ResponseMutations
impl Send for ResponseMutations
impl Sync for ResponseMutations
impl Unpin for ResponseMutations
impl UnwindSafe for ResponseMutations
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).