init(web): add loading configuration from file
This commit is contained in:
parent
b42542931a
commit
1acb32aea0
24
web/conf/conf.go
Normal file
24
web/conf/conf.go
Normal file
@ -0,0 +1,24 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const CONF_FILE = "/etc/skazanull/web.conf.yml"
|
||||
|
||||
type Conf struct {
|
||||
DBConfig string `yaml:"db_config"`
|
||||
Interface string `yaml:"interface"`
|
||||
EncryptionKey string `yaml:"encryption_key"`
|
||||
}
|
||||
|
||||
func GetConf() (conf Conf, err error) {
|
||||
confFile, err := os.ReadFile(CONF_FILE)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = yaml.Unmarshal(confFile, &conf)
|
||||
return
|
||||
}
|
||||
10
web/web.conf.yml.example
Normal file
10
web/web.conf.yml.example
Normal file
@ -0,0 +1,10 @@
|
||||
# Database configuration string
|
||||
db_config: postgres://user:password@host:port/db?application_name=SkazaNull%20Web
|
||||
|
||||
# The interface on which to run the webserver
|
||||
interface: ":9672"
|
||||
|
||||
# Encryption key for sessions.
|
||||
# Change it to a string of exactly 16, 32 or 64 chars
|
||||
# Avoid the "#" character in your APP_KEY, it may break things.
|
||||
encryption_key: some_secret_key
|
||||
Loading…
x
Reference in New Issue
Block a user