wantguns / bin

highly opinionated, minimal pastebin
https://basedbin.fly.dev
GNU Lesser General Public License v3.0
213 stars 20 forks source link

Add cache-busting and server headers with a wrapper. #5

Closed NoraCodes closed 2 years ago

NoraCodes commented 2 years ago

In order to support custom headers for various response types, this commit adds a wrapper type, ResponseWrapper, which can service all types of response in bin.

For paste objects, the preferred Last-Modified is used, so that caches can compare their exact timings with the HEAD response when revalidating.

For static objects, an ETag is used instead, based on the Cargo version and git hash of the codebase at compilation time; a build.rs is used for this.


wantguns commented 2 years ago

Thanks for the PR ! It surely sets a strong foundation for any upcoming changes. I am gonna merge this as is, those comments were more like notes.