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

CacheDirective enum is missing some directives #2666

Open
ssokolow opened this issue Feb 26, 2022 · 3 comments
Open

CacheDirective enum is missing some directives #2666

ssokolow opened this issue Feb 26, 2022 · 3 comments
Labels
A-web project: actix-web C-improvement Category: an improvement to existing functionality

Comments

@ssokolow
Copy link

Expected Behavior

I should be able to use CacheDirective::Immutable for implementing Cache-Control headers for the cache-busting pattern.

Current Behavior

I have to use CacheDirective::Extension("immutable".to_owned(), None)

Possible Solution

Add CacheDirective variants for the following variants listed on MDN but missing from the enum:

  • must-understand
  • immutable
  • stale-while-revalidate
  • stale-if-error

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.59.0 (9d1b2106e 2022-02-23)
  • Actix Web Version: 4.0.1
@robjtede robjtede added A-web project: actix-web C-improvement Category: an improvement to existing functionality labels Feb 26, 2022
@robjtede
Copy link
Member

robjtede commented Mar 1, 2022

shame this wasn't caught before stable v4 :/

you can implement your own typed headers though

@ssokolow
Copy link
Author

ssokolow commented Mar 1, 2022

shame this wasn't caught before stable v4 :/

Yeah, especially since it was just coincidence that I happened to be preparing to get back to work on the project in question around the v4 release.

To be honest, I'm surprised you didn't mark that enum nonexhaustive.

you can implement your own typed headers though

Not really worth the trouble. I only use it in one place (a helper macro for asset routes), so it's more about moving the responsibility for ensuring typos don't creep in to somewhere with more eyeballs.

@robjtede robjtede added this to the actix-web v5.0 milestone Mar 1, 2022
@robjtede
Copy link
Member

robjtede commented Mar 8, 2022

Since this can't be fixed until v5, I added an updated verison to actix-web-lab: https://docs.rs/actix-web-lab/0.15.0/actix_web_lab/header/struct.CacheControl.html.

@robjtede robjtede changed the title CacheDirective enum is missing some directives CacheDirective enum is missing some directives Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web C-improvement Category: an improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants