From 3b16dd837a203fc4865e94a031b64a83080e12ef Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Thu, 20 Jun 2019 16:29:48 +0300 Subject: Feature(http): Cors - support exposedHeaders option --- service/http/config.go | 1 + service/http/service.go | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'service/http') diff --git a/service/http/config.go b/service/http/config.go index 2897d1f7..e2f42626 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -50,6 +50,7 @@ type CORSMiddlewareConfig struct { AllowedMethods string AllowedHeaders string AllowCredentials *bool + ExposedHeaders string MaxAge int } diff --git a/service/http/service.go b/service/http/service.go index 527aca1b..f394f6af 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -315,6 +315,10 @@ func addCORSHeaders(w http.ResponseWriter, r *http.Request, options *CORSMiddlew headers.Set("Access-Control-Allow-Headers", options.AllowedHeaders) } + if options.ExposedHeaders != "" { + headers.Set("Access-Control-Expose-Headers", options.ExposedHeaders) + } + if options.AllowCredentials != nil { headers.Set("Access-Control-Allow-Credentials", strconv.FormatBool(*options.AllowCredentials)) } -- cgit v1.2.3