Files
comicverse/lib/middleware/cache.go
Gustavo L de Mello (Guz) 218b991caa refactor(lib): move app routing to lib package
These packages and functions under lib will one day be part of it's
dedicated library/framework, so separating them here helps for the
future.
2024-10-23 19:06:03 -03:00

13 lines
290 B
Go

package middleware
import (
"net/http"
)
func CacheMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "max-age=604800, stale-while-revalidate=86400, public")
next.ServeHTTP(w, r)
})
}