chore: only allow cors middleware to change headers (#1276)

This commit is contained in:
Kevin Wan
2021-11-26 14:14:06 +08:00
committed by GitHub
parent c800f6f723
commit 3dda557410
4 changed files with 12 additions and 9 deletions

View File

@@ -114,8 +114,8 @@ func TestCorsHandlerWithOrigins(t *testing.T) {
r := httptest.NewRequest(method, "http://localhost", nil)
r.Header.Set(originHeader, test.reqOrigin)
w := httptest.NewRecorder()
handler := Middleware(func(w http.ResponseWriter) {
w.Header().Set("foo", "bar")
handler := Middleware(func(header http.Header) {
header.Set("foo", "bar")
}, test.origins...)(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})