Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we get string representation for CacheControl #146

Open
sadokmtir opened this issue Aug 24, 2023 · 1 comment
Open

Could we get string representation for CacheControl #146

sadokmtir opened this issue Aug 24, 2023 · 1 comment

Comments

@sadokmtir
Copy link

I am using this crate for dealing with headers for example Cache-Control and I find it very helpful to create headers in general with this lib. But unfortunately most of the headers Structs they do not provide a string representation so we could include the headers in the response.

Example:

           let mut res = axum::response::Response::builder();

            let cache_control_value = axum::headers::CacheControl::new()
                .with_max_age(Duration::new(10, 0))
                .with_public();
            res = res.header(CACHE_CONTROL, cache_control_value.as_str());

Something like that would be very useful not only for Cache-Control but for most headers

@sadokmtir sadokmtir changed the title Could we get string representation for Cache-Control Could we get string representation for CacheControl Aug 24, 2023
@seanmonstar
Copy link
Member

The typed headers are meant to be used with HeaderMapExt, which allow a typed_insert(). CacheControl in particular doesn't have a cheap way to provide an as_str() representation, since it's internally a bunch of a flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants