mirror of
https://github.com/gomods/athens
synced 2026-02-12 05:08:08 +00:00
* Proxy: add cache-control middleware * fix improt cycle + use MDN no-cache example * remove import lines * actually use MDN example * remove .idea from gitignore in unrelated pr
17 lines
472 B
Go
17 lines
472 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/gobuffalo/buffalo"
|
|
)
|
|
|
|
// CacheControl takes a string and makes a header value to the key Cache-Control.
|
|
// This is so you can set some sane cache defaults to certain endpoints.
|
|
func CacheControl(cacheHeaderValue string) buffalo.MiddlewareFunc {
|
|
return func(next buffalo.Handler) buffalo.Handler {
|
|
return func(c buffalo.Context) error {
|
|
c.Response().Header().Set("Cache-Control", cacheHeaderValue)
|
|
return next(c)
|
|
}
|
|
}
|
|
}
|