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>
Rocket's templating is not exactly friendly when it comes to embedding
in-binary. Rocket's template fairing requires a `template_dir` directory
pointing to the directory containing templates.
A quick workaround to this would be to have custom fairings with
`template_dir` merged with the value `.`
But in bare-metal scenarios like what docker's scratch image mimics, we
don't exactly have a '.' file, so instead for this very project, I have
to point the `template_dir` to the `upload` folder, which is created by
`bin` on execution. Checkout the Dockerfile for more info
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
Builds static binaries instead to be runnable from scratch. This eases
the build process, as we don't have to depend on docker's buildx.
Now images for both arm64 and x86_64 can be built on x86_64 platform
alone.
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
Unfortunately, since fetch API does not support getting progress while
perfoming uploads, we cannot have a more dynamic cue
Signed-off-by: Gunwant Jain <mail@wantguns.dev>