Struct axum_core::response::AppendHeaders
source · [−]Expand description
Append headers to a response.
Returning something like [("content-type", "foo=bar")]
from a handler will override any
existing content-type
headers. If instead you want to append headers, use AppendHeaders
:
use axum::{
response::{AppendHeaders, IntoResponse},
http::header::SET_COOKIE,
};
async fn handler() -> impl IntoResponse {
// something that sets the `set-cookie` header
let set_some_cookies = /* ... */
(
set_some_cookies,
// append two `set-cookie` headers to the response
// without overriding the ones added by `set_some_cookies`
AppendHeaders([
(SET_COOKIE, "foo=bar"),
(SET_COOKIE, "baz=qux"),
])
)
}
Tuple Fields
0: [(K, V); N]
Trait Implementations
sourceimpl<K, V, const N: usize> IntoResponse for AppendHeaders<K, V, N>where
K: TryInto<HeaderName>,
K::Error: Display,
V: TryInto<HeaderValue>,
V::Error: Display,
impl<K, V, const N: usize> IntoResponse for AppendHeaders<K, V, N>where
K: TryInto<HeaderName>,
K::Error: Display,
V: TryInto<HeaderValue>,
V::Error: Display,
sourcefn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
sourceimpl<K, V, const N: usize> IntoResponseParts for AppendHeaders<K, V, N>where
K: TryInto<HeaderName>,
K::Error: Display,
V: TryInto<HeaderValue>,
V::Error: Display,
impl<K, V, const N: usize> IntoResponseParts for AppendHeaders<K, V, N>where
K: TryInto<HeaderName>,
K::Error: Display,
V: TryInto<HeaderValue>,
V::Error: Display,
type Error = TryIntoHeaderError<<K as TryInto<HeaderName>>::Error, <V as TryInto<HeaderValue>>::Error>
type Error = TryIntoHeaderError<<K as TryInto<HeaderName>>::Error, <V as TryInto<HeaderValue>>::Error>
The type returned in the event of an error. Read more
sourcefn into_response_parts(
self,
res: ResponseParts
) -> Result<ResponseParts, Self::Error>
fn into_response_parts(
self,
res: ResponseParts
) -> Result<ResponseParts, Self::Error>
Set parts of the response
Auto Trait Implementations
impl<K, V, const N: usize> RefUnwindSafe for AppendHeaders<K, V, N>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const N: usize> Send for AppendHeaders<K, V, N>where
K: Send,
V: Send,
impl<K, V, const N: usize> Sync for AppendHeaders<K, V, N>where
K: Sync,
V: Sync,
impl<K, V, const N: usize> Unpin for AppendHeaders<K, V, N>where
K: Unpin,
V: Unpin,
impl<K, V, const N: usize> UnwindSafe for AppendHeaders<K, V, N>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more