diff options
Diffstat (limited to 'service/http/config.go')
-rw-r--r-- | service/http/config.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/service/http/config.go b/service/http/config.go index 5454f124..e2f42626 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -33,10 +33,40 @@ type Config struct { // HTTP2 configuration HTTP2 *HTTP2Config + // Middlewares + Middlewares *MiddlewaresConfig + // Workers configures rr server and worker pool. Workers *roadrunner.ServerConfig } +type MiddlewaresConfig struct { + Headers *HeaderMiddlewareConfig + CORS *CORSMiddlewareConfig +} + +type CORSMiddlewareConfig struct { + AllowedOrigin string + AllowedMethods string + AllowedHeaders string + AllowCredentials *bool + ExposedHeaders string + MaxAge int +} + +type HeaderMiddlewareConfig struct { + CustomRequestHeaders map[string]string + 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 +} + type FCGIConfig struct { // Port and port to handle as http server. Address string @@ -73,6 +103,10 @@ func (c *Config) EnableHTTP() bool { return c.Address != "" } +func (c *Config) EnableMiddlewares() bool { + return c.Middlewares != nil +} + // EnableTLS returns true if rr must listen TLS connections. func (c *Config) EnableTLS() bool { return c.SSL.Key != "" || c.SSL.Cert != "" |