chore: omit empty config

This commit is contained in:
Jonas Kaninda
2024-11-22 18:19:20 +01:00
parent 7369d5eebf
commit e3edd37cd3
3 changed files with 13 additions and 27 deletions

View File

@@ -86,7 +86,7 @@ It's designed to be straightforward and efficient, offering a rich set of featur
Use a round-robin algorithm for efficient load distribution. Use a round-robin algorithm for efficient load distribution.
### Configuration and Flexibility ### Configuration and Flexibility
- **Support for Multiple Route Configuration Files** - **Support for Multiple Route and Middleware Configuration Files**
Organize routes across multiple `.yml` or `.yaml` files. Organize routes across multiple `.yml` or `.yaml` files.
- **TLS Support** - **TLS Support**

View File

@@ -133,23 +133,9 @@ func initConfig(configFile string) error {
conf := &GatewayConfig{ conf := &GatewayConfig{
Version: util.ConfigVersion, Version: util.ConfigVersion,
GatewayConfig: Gateway{ GatewayConfig: Gateway{
WriteTimeout: 15, WriteTimeout: 15,
ReadTimeout: 15, ReadTimeout: 15,
IdleTimeout: 30, IdleTimeout: 30,
AccessLog: "/dev/Stdout",
ErrorLog: "/dev/stderr",
DisableRouteHealthCheckError: false,
DisableDisplayRouteOnStart: false,
RateLimit: 0,
InterceptErrors: []int{405, 500},
Cors: Cors{
Origins: []string{"http://localhost:8080", "https://example.com"},
Headers: map[string]string{
"Access-Control-Allow-Headers": "Origin, Authorization, Accept, Content-Type, Access-Control-Allow-Headers",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Max-Age": "1728000",
},
},
Routes: []Route{ Routes: []Route{
{ {
Name: "Example", Name: "Example",

View File

@@ -32,26 +32,26 @@ type Gateway struct {
// IdleTimeout defines proxy idle timeout // IdleTimeout defines proxy idle timeout
IdleTimeout int `yaml:"idleTimeout" env:"GOMA_IDLE_TIMEOUT, overwrite"` IdleTimeout int `yaml:"idleTimeout" env:"GOMA_IDLE_TIMEOUT, overwrite"`
// RateLimit Defines the number of request peer minutes // RateLimit Defines the number of request peer minutes
RateLimit int `yaml:"rateLimit" env:"GOMA_RATE_LIMIT, overwrite"` RateLimit int `yaml:"rateLimit,omitempty" env:"GOMA_RATE_LIMIT, overwrite"`
// BlockCommonExploits enable, disable block common exploits // BlockCommonExploits enable, disable block common exploits
BlockCommonExploits bool `yaml:"blockCommonExploits"` BlockCommonExploits bool `yaml:"blockCommonExploits,omitempty"`
AccessLog string `yaml:"accessLog" env:"GOMA_ACCESS_LOG, overwrite"` AccessLog string `yaml:"accessLog,omitempty" env:"GOMA_ACCESS_LOG, overwrite"`
ErrorLog string `yaml:"errorLog" env:"GOMA_ERROR_LOG=, overwrite"` ErrorLog string `yaml:"errorLog,omitempty" env:"GOMA_ERROR_LOG=, overwrite"`
LogLevel string `yaml:"logLevel" env:"GOMA_LOG_LEVEL, overwrite"` LogLevel string `yaml:"logLevel" env:"GOMA_LOG_LEVEL, overwrite"`
// DisableHealthCheckStatus enable and disable routes health check // DisableHealthCheckStatus enable and disable routes health check
DisableHealthCheckStatus bool `yaml:"disableHealthCheckStatus"` DisableHealthCheckStatus bool `yaml:"disableHealthCheckStatus"`
// DisableRouteHealthCheckError allows enabling and disabling backend healthcheck errors // DisableRouteHealthCheckError allows enabling and disabling backend healthcheck errors
DisableRouteHealthCheckError bool `yaml:"disableRouteHealthCheckError"` DisableRouteHealthCheckError bool `yaml:"disableRouteHealthCheckError,omitempty"`
// Disable allows enabling and disabling displaying routes on start // Disable allows enabling and disabling displaying routes on start
DisableDisplayRouteOnStart bool `yaml:"disableDisplayRouteOnStart"` DisableDisplayRouteOnStart bool `yaml:"disableDisplayRouteOnStart,omitempty"`
// DisableKeepAlive allows enabling and disabling KeepALive server // DisableKeepAlive allows enabling and disabling KeepALive server
DisableKeepAlive bool `yaml:"disableKeepAlive"` DisableKeepAlive bool `yaml:"disableKeepAlive,omitempty"`
EnableMetrics bool `yaml:"enableMetrics"` EnableMetrics bool `yaml:"enableMetrics"`
// InterceptErrors holds the status codes to intercept the error from backend // InterceptErrors holds the status codes to intercept the error from backend
InterceptErrors []int `yaml:"interceptErrors"` InterceptErrors []int `yaml:"interceptErrors,omitempty"`
// Cors holds proxy global cors // Cors holds proxy global cors
Cors Cors `yaml:"cors"` Cors Cors `yaml:"cors,omitempty"`
// ExtraRoutes additional routes from defined directory // ExtraRoutes additional routes from defined directory
ExtraRoutes ExtraRouteConfig `yaml:"extraRoutes"` ExtraRoutes ExtraRouteConfig `yaml:"extraRoutes"`
// Routes holds proxy routes // Routes holds proxy routes