mirror of
https://github.com/pushbits/server.git
synced 2025-06-10 14:42:01 +02:00
Initialize repository
This commit is contained in:
commit
1d758fcfd0
28 changed files with 1107 additions and 0 deletions
43
configuration/configuration.go
Normal file
43
configuration/configuration.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package configuration
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/configor"
|
||||
)
|
||||
|
||||
// Configuration holds values that can be configured by the user.
|
||||
type Configuration struct {
|
||||
Database struct {
|
||||
Dialect string `default:"sqlite3"`
|
||||
Connection string `default:"pushbits.db"`
|
||||
}
|
||||
Admin struct {
|
||||
Name string `default:"admin"`
|
||||
Password string `default:"admin"`
|
||||
MatrixID string `required:"true"`
|
||||
}
|
||||
Matrix struct {
|
||||
Homeserver string `default:"https://matrix.org"`
|
||||
Username string `required:"true"`
|
||||
Password string `required:"true"`
|
||||
}
|
||||
}
|
||||
|
||||
func configFiles() []string {
|
||||
return []string{"config.yml"}
|
||||
}
|
||||
|
||||
// Get returns the configuration extracted from env variables or config file.
|
||||
func Get() *Configuration {
|
||||
config := new(Configuration)
|
||||
|
||||
err := configor.New(&configor.Config{
|
||||
Environment: "production",
|
||||
ENVPrefix: "PUSHBITS",
|
||||
ErrorOnUnmatchedKeys: true,
|
||||
}).Load(config, configFiles()...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue