mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 11:21:42 +00:00
Merge pull request #3 from Fishwaldo/headers
add AddAllowedHeaders function to whitelist common headers
This commit is contained in:
commit
e25bcfc777
1 changed files with 10 additions and 0 deletions
10
context.go
10
context.go
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue