pub struct AppendHeaders<K, V, const N: usize>(pub [(K, V); N]);
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

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Should always be Self

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more