Skip to content

Add multiple headers in SetResponseHeaderLayer or similarΒ #571

Open
@lf-

Description

@lf-
  • I have looked for existing issues (including closed) about this

Feature Request

I want to be able to set multiple headers with SetResponseHeaderLayer: needing one layer per header (plus me having issues returning impl Layer<S> relating to Send, Sync, etc), means that to set a bunch of default headers in a separate function than the one defining the service itself requires naming a type that is really long, made of a pile of tower::layer::util::Stack.

The use case for this is stuff like X-Content-Type-Options, X-Frame-Options, etc.

Motivation

There's a crate tower-default-headers which does this, but it's a third party crate and a pretty common use case.

Proposal

Some kind of SetResponseHeadersLayer that allows setting multiple headers, either using a Vec of them or a compile-time array or so.

Alternatives

Just use the third party crate;
Just write your own middleware which involves unfun async shenanigans.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions