diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-11-09 22:05:17 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-11-09 22:05:17 -0500 |
| commit | 494c954cbb8dfd618f06eb51193b472a3f23f7cd (patch) | |
| tree | 2d04846f6d74b624b676509c5350be6ca6429625 /src/invidious.cr | |
| parent | 71bc9eea28ed6fb22992d774443f64ce1d1551be (diff) | |
| download | invidious-494c954cbb8dfd618f06eb51193b472a3f23f7cd.tar.gz invidious-494c954cbb8dfd618f06eb51193b472a3f23f7cd.tar.bz2 invidious-494c954cbb8dfd618f06eb51193b472a3f23f7cd.zip | |
Add etag to /api/v1/annotations
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 06f9e624..96c3d6e9 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4042,7 +4042,13 @@ get "/api/v1/annotations/:id" do |env| annotations = response.body end - annotations + etag = sha256(annotations)[0, 16] + if env.request.headers["If-None-Match"]?.try &.== etag + env.response.status_code = 304 + else + env.response.headers["ETag"] = etag + annotations + end end get "/api/v1/videos/:id" do |env| |
