Merge pull request #3 from Fishwaldo/headers

add AddAllowedHeaders function to whitelist common headers
This commit is contained in:
Justin Hammond 2022-08-20 00:13:50 +08:00 committed by GitHub
commit e25bcfc777
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,16 @@ var allowedHeaders = map[string]bool{
"vary": true,
}
// AddAllowedHeader adds a header to the list of allowed headers for the response.
// This is useful for common headers that might be sent due to middleware
// or other frameworks
func AddAllowedHeaders(name ...string) {
for _, h := range name {
allowedHeaders[strings.ToLower(h)] = true
}
}
// ContextFromRequest returns a Huma context for a request, useful for
// accessing high-level convenience functions from e.g. middleware.
func ContextFromRequest(w http.ResponseWriter, r *http.Request) Context {