Add etag to /api/v1/annotations

This commit is contained in:
Omar Roth 2019-11-09 22:05:17 -05:00
parent 71bc9eea28
commit 494c954cbb
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2

View file

@ -4042,7 +4042,13 @@ get "/api/v1/annotations/:id" do |env|
annotations = response.body
end
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|