mirror of
https://github.com/gomods/athens
synced 2026-02-03 09:50:31 +00:00
* Remove Buffalo * gofmt * pr fixes * fix subrouter * bring back secure middleware + pr fixes * better place for subrouter * vendor
24 lines
528 B
Go
24 lines
528 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestCacheControl(t *testing.T) {
|
|
h := func(w http.ResponseWriter, r *http.Request) {}
|
|
expected := "private, no-store"
|
|
ch := CacheControl(expected)
|
|
handler := ch(http.HandlerFunc(h))
|
|
|
|
w := httptest.NewRecorder()
|
|
r, _ := http.NewRequest("GET", "/test", nil)
|
|
handler.ServeHTTP(w, r)
|
|
|
|
given := w.Result().Header.Get("Cache-Control")
|
|
if given != expected {
|
|
t.Fatalf("expected cache-control header to be %v but got %v", expected, given)
|
|
}
|
|
}
|