diff options
author | Dmitry Patsura <[email protected]> | 2019-06-20 14:26:33 +0300 |
---|---|---|
committer | Dmitry Patsura <[email protected]> | 2019-06-20 14:26:33 +0300 |
commit | 878f2d546969e522a9bf5a964f626e3b823ce9a0 (patch) | |
tree | 70f77bb4f17421d869d5f476954b4325b86fb34c /service/http/config.go | |
parent | 4a94c0cb578e5dca6bb43d60127121a16e7217b2 (diff) |
Feature(http): Introduce CORS middleware
Diffstat (limited to 'service/http/config.go')
-rw-r--r-- | service/http/config.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/service/http/config.go b/service/http/config.go index 2b8cf049..2897d1f7 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -42,6 +42,15 @@ type Config struct { type MiddlewaresConfig struct { Headers *HeaderMiddlewareConfig + CORS *CORSMiddlewareConfig +} + +type CORSMiddlewareConfig struct { + AllowedOrigin string + AllowedMethods string + AllowedHeaders string + AllowCredentials *bool + MaxAge int } type HeaderMiddlewareConfig struct { @@ -49,6 +58,10 @@ type HeaderMiddlewareConfig struct { CustomResponseHeaders map[string]string } +func (c *MiddlewaresConfig) EnableCORS() bool { + return c.CORS != nil +} + func (c *MiddlewaresConfig) EnableHeaders() bool { return c.Headers.CustomRequestHeaders != nil || c.Headers.CustomResponseHeaders != nil } |