Documentation ¶
Overview ¶
The module is resposible for finding, parsing and merging the HTTPMS user configuration with the default. Configuration locations should be different depending on the host OS.
Linux/BSD configurations should be in $HOME/.httpms/config.json Windows configurations should be in %APPDATA%/httpms/config.json
Index ¶
Constants ¶
const CONFIG_NAME = "config.json"
const DEFAULT_CONFIG_NAME = "config.default.json"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Listen string `json:"listen"` SSL bool `json:"ssl"` SSLCertificate ConfigCert `json:"ssl_certificate"` Auth bool `json:"basic_authenticate"` Authenticate ConfigAuth `json:"authentication"` Libraries []string `json:"libraries"` UserPath string `json:"user_path"` LogFile string `json:"log_file"` SqliteDatabase string `json:"sqlite_database"` Gzip bool `json:"gzip"` ReadTimeout int `json:"read_timeout"` WriteTimeout int `json:"write_timeout"` MaxHeadersSize int `json:"max_header_bytes"` HTTPRoot string `json:"http_root"` }
The configuration type. Should contain representation for everything in config.json
func (*Config) CopyDefaultOverUser ¶
Will create (or replace if neccessery) the user configuration using the default config file supplied with the installation.
func (*Config) DefaultConfigPath ¶
Returns the full path to the default configuration file
func (*Config) FindAndParse ¶
Actually finds the configuration file, parsing it and merging it on top the default configuration.
func (*Config) UserConfigExists ¶
Returns true if the user configuration is present and in order. Otherwise false.
func (*Config) UserConfigPath ¶
Returns the full path to the place where the user's configuration file should be
type ConfigAuth ¶
type ConfigCert ¶
type MergedConfig ¶
type MergedConfig struct { Listen *string `json:"listen"` SSL *bool `json:"ssl"` SSLCertificate *ConfigCert `json:"ssl_certificate"` Auth *bool `json:"basic_authenticate"` Authenticate *ConfigAuth `json:"authentication"` Libraries *[]string `json:"libraries"` UserPath *string `json:"user_path"` LogFile *string `json:"log_file"` SqliteDatabase *string `json:"sqlite_database"` Gzip *bool `json:"gzip"` ReadTimeout *int `json:"read_timeout"` WriteTimeout *int `json:"write_timeout"` MaxHeadersSize *int `json:"max_header_bytes"` HTTPRoot *string `json:"http_root"` }
Used for merging one config over the other. I need the zero value for every Field to be nil so that I can destinguish if it has been in the json file or not. If I did not use pointers I would not have been able to do that. That way the merged (user) json can contain a subset of all fields and everything else will be used from the default json. Unfortunatelly this leads to repetition since MergedConfig must have the same fields in the same order as Config.