mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
[config] introduce mode selection
This commit is contained in:
parent
7d44d54aed
commit
9dcb01f170
@ -1,3 +1,6 @@
|
||||
gateway:
|
||||
mode: private
|
||||
private_token: 123456789
|
||||
http: # http server config
|
||||
listen: 127.0.0.1:3000 # listen address
|
||||
database: # database
|
||||
|
||||
@ -1,21 +1,34 @@
|
||||
package config
|
||||
|
||||
type GatewayMode string
|
||||
|
||||
const (
|
||||
GatewayModePublic GatewayMode = "public"
|
||||
GatewayModePrivate GatewayMode = "private"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Gateway Gateway `yaml:"gateway"`
|
||||
HTTP HTTP `yaml:"http"`
|
||||
Database Database `yaml:"database"`
|
||||
FCM FCMConfig `yaml:"fcm"`
|
||||
Tasks Tasks `yaml:"tasks"`
|
||||
}
|
||||
|
||||
type Gateway struct {
|
||||
Mode GatewayMode `yaml:"mode" envconfig:"GATEWAY__MODE"` // gateway mode: public or private
|
||||
PrivateToken string `yaml:"private_token" envconfig:"GATEWAY__PRIVATE_TOKEN"` // device registration token in private mode
|
||||
}
|
||||
|
||||
type HTTP struct {
|
||||
Listen string `yaml:"listen" envconfig:"HTTP__LISTEN"`
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
Dialect string `yaml:"dialect" envconfig:"DATABASE__DIALECT"`
|
||||
Host string `yaml:"host" envconfig:"DATABASE__HOST"`
|
||||
Port int `yaml:"port" envconfig:"DATABASE__PORT"`
|
||||
User string `yaml:"user" envconfig:"DATABASE__USER"`
|
||||
Dialect string `yaml:"dialect" envconfig:"DATABASE__DIALECT"`
|
||||
Host string `yaml:"host" envconfig:"DATABASE__HOST"`
|
||||
Port int `yaml:"port" envconfig:"DATABASE__PORT"`
|
||||
User string `yaml:"user" envconfig:"DATABASE__USER"`
|
||||
Password string `yaml:"password" envconfig:"DATABASE__PASSWORD"`
|
||||
Database string `yaml:"database" envconfig:"DATABASE__DATABASE"`
|
||||
Timezone string `yaml:"timezone" envconfig:"DATABASE__TIMEZONE"`
|
||||
@ -36,6 +49,7 @@ type HashingTask struct {
|
||||
}
|
||||
|
||||
var defaultConfig = Config{
|
||||
Gateway: Gateway{Mode: GatewayModePublic},
|
||||
HTTP: HTTP{
|
||||
Listen: ":3000",
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user