[#56] Add Allow-Origin header to all responses

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-08-25 16:46:58 +03:00 committed by Kirillov Denis
parent ab2a2abbd5
commit d99c248a46

View file

@ -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))
}) })
} }