pub struct AppendHeaders<I>(pub I);
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: I

Trait Implementations§

Formats the value using the given formatter. Read more
Create a response.
The type returned in the event of an error. Read more
Set parts of the response

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.