Documentation ¶
Overview ¶
Package config sets up the configuration for the server. The configuration settings may be from the default built-in configuration, read from a file, read from an io.Reader or specifically set.
Typically the default built-in configuration is created using config.Default and then settings from a configuration file applied using config.Load, as this allows for omitted values in the configuration file to use the defaults. The configuration is not used directly, instead it should be passed to the various package level Config methods by the main function.
The default server configuration is documented in docs/configuration-file.txt
Index ¶
Constants ¶
const DefaultCfg = `` /* 499-byte string literal not displayed */
DefaultCfg is the default built-in server configuration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.0.19
type Config struct { Server Server Quota Quota Stats Stats Inventory Inventory Login Login Debug Debug Greeting string }
Config represents the server's configuration.
func Default ¶ added in v0.0.19
func Default() Config
Default returns the default, built-in server configuration. Failure to create the default built-in configuration is fatal.
func (Config) Load ¶ added in v0.0.19
Load loads the configuration specified by the passed path. The passed path may be relative or absolute, a path ending in a path separator (in which case the default file 'config.wrj' will be used) or a configuration file name (which will be prefixed with the default path e.g. '../data').
The receiver is used as a base configuration and the loaded configuration is applied over it. This allows settings omitted from the loaded configuration to use any defaults set in the base configuration. Returns the new configuration and a nil error on success. On failure returns a copy of the base configuration and a non-nil error.
func (Config) Read ¶ added in v0.0.19
Read reads configuration settings from the passed io.Reader. The receiver is used as a base configuration and the read settings are applied over it. This allows settings omitted from the read configuration to use any defaults set in the base configuration. Returns the new configuration and nil error on success. On failure returns a copy of the base configuration and a non-nil error.