Documentation
¶
Overview ¶
Package config handles application and mock configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CLIOverrides ¶ added in v0.13.0
type CLIOverrides struct {
Port int
Addr string
LogLevel string
Verbose bool
ReadTimeout string
WriteTimeout string
IdleTimeout string
}
CLIOverrides holds CLI flag values that override config settings.
type Config ¶
type Config struct {
Server struct {
Addr string
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
}
Logger struct {
Level string
}
}
Config represents configuration of application.
func (*Config) ApplyOverrides ¶ added in v0.13.0
func (c *Config) ApplyOverrides(overrides CLIOverrides)
ApplyOverrides applies CLI flag overrides to the config.
type Endpoint ¶
type Endpoint struct {
Methods []string `json:"methods,omitempty"`
Status int `json:"status,omitempty"`
Path string `json:"path"`
Delay int `json:"delay,omitempty"`
JSONPath string `json:"jsonPath,omitempty"` // path to the JSON file with endpoint
JSON any `json:"json,omitempty"`
Proxy string `json:"proxy,omitempty"`
Static string `json:"static,omitempty"` // static file server
Errors *Errors `json:"errors,omitempty"`
AllowCors []string `json:"allowCors,omitempty"`
Dynamic *struct {
Write *struct {
JSON *struct {
Name string `json:"name"` // entity name
Key string `json:"key"` // path/to/a/key to store from an incoming JSON
Value string `json:"value"` // path/to/a/value to store from an incoming JSON
} `json:"json,omitempty"`
} `json:"write,omitempty"`
Read *struct {
JSON *struct {
Name string `json:"name"` // entity name
KeyParam string `json:"keyParam,omitempty"` // key parameter name from the "path"
} `json:"json,omitempty"`
} `json:"read,omitempty"`
} `json:"dynamic,omitempty"`
}
Endpoint represents API endpoint configuration.
type Errors ¶ added in v0.3.0
type Errors struct {
Sample float32 `json:"sample,omitempty"`
Statuses []int `json:"statuses,omitempty"`
}
Errors represents error simulation configuration.
type Mock ¶
type Mock struct {
Port int `json:"port,omitempty"`
Addr string `json:"addr,omitempty"`
ReadTimeout string `json:"readTimeout,omitempty"`
WriteTimeout string `json:"writeTimeout,omitempty"`
IdleTimeout string `json:"idleTimeout,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Endpoints []*Endpoint `json:"endpoints"`
}
Mock represents configuration of API.
Click to show internal directories.
Click to hide internal directories.