forked from TrueCloudLab/frostfs-rest-gw
[#56] Add Allow-Origin header to all responses
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
ab2a2abbd5
commit
d99c248a46
1 changed files with 4 additions and 0 deletions
|
@ -69,6 +69,8 @@ const (
|
||||||
ContextKeyRequestID ContextKey = "requestID"
|
ContextKeyRequestID ContextKey = "requestID"
|
||||||
|
|
||||||
docsPrefix = "/docs"
|
docsPrefix = "/docs"
|
||||||
|
|
||||||
|
accessControlAllowOriginHeader = "Access-Control-Allow-Origin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates a new API using specified logger, connection pool and other parameters.
|
// New creates a new API using specified logger, connection pool and other parameters.
|
||||||
|
@ -165,6 +167,8 @@ func (a *API) setupGlobalMiddleware(handler http.Handler) http.Handler {
|
||||||
|
|
||||||
ctx := context.WithValue(r.Context(), ContextKeyRequestID, requestID)
|
ctx := context.WithValue(r.Context(), ContextKeyRequestID, requestID)
|
||||||
|
|
||||||
|
w.Header().Set(accessControlAllowOriginHeader, allOrigins)
|
||||||
|
|
||||||
handler.ServeHTTP(w, r.WithContext(ctx))
|
handler.ServeHTTP(w, r.WithContext(ctx))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue