mirror of
https://github.com/gomods/athens
synced 2026-02-03 08:40:31 +00:00
* Remove Buffalo * gofmt * pr fixes * fix subrouter * bring back secure middleware + pr fixes * better place for subrouter * vendor
21 lines
501 B
Go
21 lines
501 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
// 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) mux.MiddlewareFunc {
|
|
return func(h http.Handler) http.Handler {
|
|
f := func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Cache-Control", cacheHeaderValue)
|
|
h.ServeHTTP(w, r)
|
|
}
|
|
|
|
return http.HandlerFunc(f)
|
|
}
|
|
}
|