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:
parent
55ed495b83
commit
2ab7ddb9c8
12 changed files with 291 additions and 152 deletions
9
build.rs
Normal file
9
build.rs
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue