Skip to content

Commit 3141e90

Browse files
committed
last-mod for sync
1 parent 78b47e2 commit 3141e90

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/main/com/yetanalytics/lrs/pedestal/routes/statements.cljc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,16 @@
172172
ctx
173173
:response
174174
(if (or statement statement-result)
175-
(if (get-in xapi [:xapi.statements.GET.request/params :attachments])
175+
(let [?last-mod
176+
(or (get statement "stored")
177+
(some-> statement-result
178+
:statements
179+
first
180+
(get "stored")))]
181+
(if (get-in xapi [:xapi.statements.GET.request/params :attachments])
176182
{:status 200
177-
:headers (cond-> {"Content-Type" att-resp/content-type}
183+
:headers (cond-> (cond-> {"Content-Type" att-resp/content-type}
184+
?last-mod (assoc "last-modified" ?last-mod))
178185
etag (assoc "etag" etag))
179186
;; shim, the protocol will be expected to return this
180187
:body (att-resp/build-multipart-async
@@ -202,7 +209,8 @@
202209
(if statement-result
203210
;; Multiple statements
204211
{:status 200
205-
:headers {"Content-Type" "application/json"}
212+
:headers (cond-> {"Content-Type" "application/json"}
213+
?last-mod (assoc "last-modified" ?last-mod))
206214
:body (si/lazy-statement-result-async
207215
(a/to-chan!
208216
(concat (cons :statements
@@ -213,7 +221,9 @@
213221
;; TODO: if content-type headers get set here the body
214222
;; is not coerced
215223
{:status 200
216-
:body statement})))
224+
:headers (cond-> {}
225+
?last-mod (assoc "last-modified" ?last-mod))
226+
:body statement}))))
217227
;; Not found
218228
{:status 404 :body ""}))
219229
(catch #?(:clj Exception

0 commit comments

Comments
 (0)