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

@@ -322,8 +322,10 @@ Port: 54321
srv, err := NewServer(cnf, WithRouter(rt))
assert.Nil(t, err)
opt := WithCustomCors(func(w http.ResponseWriter) {
w.Header().Set("foo", "bar")
opt := WithCustomCors(func(header http.Header) {
header.Set("foo", "bar")
}, func(w http.ResponseWriter) {
w.WriteHeader(http.StatusOK)
}, "local")
opt(srv)
}