Commit Graph

9 Commits

Author SHA1 Message Date
Leonora Tindall
24c7f43608 Fix typo: pretter -> pretty 2022-04-26 22:40:28 +05:30
Gunwant Jain
0305742d6d Apply clippy suggestions
Use the latest rust version

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
2022-03-15 14:03:08 +05:30
Gunwant Jain
08ec2cbecb Provide Cache-Control Headers
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>
2022-02-08 01:46:05 +05:30
Leonora Tindall
2ab7ddb9c8 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.
2022-02-05 06:20:33 +05:30
Leonora Tindall
5aafe2500a Redirect on invalid UTF-8 in /p/
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.
2022-02-02 12:52:24 -06:00
Gunwant Jain
edc247b558 Templates: fix the content type of templates
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>
2022-01-19 16:33:57 +05:30
Gunwant Jain
ce001c6a79 Args: implement upload arg
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
2022-01-18 15:48:21 +05:30
Gunwant Jain
80c6809414 pretty: remove dead code
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
2021-07-13 04:28:27 +05:30
Gunwant Jain
9c5a3af128 refactor: bring in the modules
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
2021-07-11 03:07:50 +05:30