actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.75k stars 1.68k forks source link

`CacheDirective` enum is missing some directives #2666

Open ssokolow opened 2 years ago

ssokolow commented 2 years ago

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:

Your Environment

robjtede commented 2 years ago

shame this wasn't caught before stable v4 :/

you can implement your own typed headers though

ssokolow commented 2 years ago

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 commented 2 years ago

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.