max-age = 1 week for everything
stale-while-revalidate = 1 day for everything except raw pastes
immutable for raw pastes
Most likely fixes#2, unless I forgot something.
Suggested-by: Leonora Tindall <ltindall@fastly.com>
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
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.
Previously, uploading a paste with invalid UTF-8 and then viewing it
with the pretty URL would cause a panic.
With this change, it simply redirects to the raw URL.
Templating is weird af in Rocket. Look into 3a541ae for more.
The content-type of the rendering is determined by the extension of the
template name.
But renaming these templates would break building the project for
development because it finds a phony template there. So the trick is to
default the `template_dir` to `args.upload` because it should never
interfere and will be always present.
This also fixes the hax in Dockerfile by making it the default.
Signed-off-by: Gunwant Jain <mail@wantguns.dev>