Add cache-busting and server headers with a wrapper.

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.
This commit is contained in:
Leonora Tindall
2022-02-04 13:47:30 -06:00
committed by Gunwant Jain
parent 55ed495b83
commit 2ab7ddb9c8
12 changed files with 292 additions and 153 deletions

9
build.rs Normal file
View File

@@ -0,0 +1,9 @@
use std::process::Command;
fn main() {
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}