mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 22:09:20 +00:00
Setup cache headers for photo routes
This commit is contained in:
@@ -103,6 +103,9 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) {
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", stats.Size()))
|
||||
}
|
||||
|
||||
// Allow caching the resource for 1 day
|
||||
w.Header().Set("Cache-Control", "private, max-age=86400, immutable")
|
||||
|
||||
io.Copy(w, file)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,12 +14,13 @@ func CORSMiddleware(devMode bool) mux.MiddlewareFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
methods := []string{http.MethodGet, http.MethodPost, http.MethodOptions}
|
||||
headers := []string{"authorization", "content-type", "content-length", "TokenPassword"}
|
||||
requestHeaders := []string{"authorization", "content-type", "content-length", "TokenPassword"}
|
||||
responseHeaders := []string{"content-length"}
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ","))
|
||||
w.Header().Set("Access-Control-Allow-Headers", strings.Join(headers, ","))
|
||||
w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ", "))
|
||||
w.Header().Set("Access-Control-Allow-Headers", strings.Join(requestHeaders, ", "))
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "content-length")
|
||||
w.Header().Set("Access-Control-Expose-Headers", strings.Join(responseHeaders, ", "))
|
||||
|
||||
endpoint := utils.ApiEndpointUrl()
|
||||
endpoint.Path = path.Join(endpoint.Path, "graphql")
|
||||
|
||||
Reference in New Issue
Block a user