forked from vikunja/vikunja
feat(background): add Last-Modified header (#1376)
Reviewed-on: vikunja/api#1376 Co-authored-by: clos <clos@noreply.kolaente.de> Co-committed-by: clos <clos@noreply.kolaente.de>
This commit is contained in:
parent
491a142378
commit
f660badc3d
@ -295,6 +295,11 @@ func GetListBackground(c echo.Context) error {
|
||||
_ = s.Rollback()
|
||||
return handler.HandleHTTPError(err, c)
|
||||
}
|
||||
stat, err := bgFile.File.Stat()
|
||||
if err != nil {
|
||||
_ = s.Rollback()
|
||||
return handler.HandleHTTPError(err, c)
|
||||
}
|
||||
|
||||
// Unsplash requires pingbacks as per their api usage guidelines.
|
||||
// To do this in a privacy-preserving manner, we do the ping from inside of Vikunja to not expose any user details.
|
||||
@ -306,6 +311,11 @@ func GetListBackground(c echo.Context) error {
|
||||
return handler.HandleHTTPError(err, c)
|
||||
}
|
||||
|
||||
// Set Last-Modified header if we have the file stat, so clients can decide whether to use cached files
|
||||
if stat != nil {
|
||||
c.Response().Header().Set(echo.HeaderLastModified, stat.ModTime().UTC().Format(http.TimeFormat))
|
||||
}
|
||||
|
||||
// Serve the file
|
||||
return c.Stream(http.StatusOK, "image/jpg", bgFile.File)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user