Ajouter flags pour api port, host et protocol

Ajouter `server.api.port`, `server.api.host`, `server.api.protocol`
This commit is contained in:
Victor Lacasse-Beaudoin 2023-07-14 19:56:12 -04:00
parent 891cddd51e
commit 04de5cdad2
2 changed files with 17 additions and 2 deletions

View file

@ -110,6 +110,18 @@ func init() {
serverCmd.Flags().String("server-api-key", "agecem-org", "Key to use for authenticating to /v1 routes") serverCmd.Flags().String("server-api-key", "agecem-org", "Key to use for authenticating to /v1 routes")
viper.BindPFlag("server.api.key", serverCmd.Flags().Lookup("server-api-key")) viper.BindPFlag("server.api.key", serverCmd.Flags().Lookup("server-api-key"))
// server.api.port
serverCmd.Flags().Int("server-api-port", 8080, "API server port (config: server.api.port)")
viper.BindPFlag("server.api.port", serverCmd.Flags().Lookup("server-api-port"))
// server.api.protocol
serverCmd.Flags().String("server-api-protocol", "http", "API server protocol (http/https) (config: server.api.protocol)")
viper.BindPFlag("server.api.protocol", serverCmd.Flags().Lookup("server-api-protocol"))
// server.api.host
serverCmd.Flags().String("server-api-host", "localhost", "API server host (config: server.api.host)")
viper.BindPFlag("server.api.host", serverCmd.Flags().Lookup("server-api-host"))
// server.admin.auth - --server-admin-auth // server.admin.auth - --server-admin-auth
serverCmd.Flags().Bool("server-admin-auth", true, "Enable to allow basic authentication for /admin routes (config: server.admin.auth)") serverCmd.Flags().Bool("server-admin-auth", true, "Enable to allow basic authentication for /admin routes (config: server.admin.auth)")
viper.BindPFlag("server.admin.auth", serverCmd.Flags().Lookup("server-admin-auth")) viper.BindPFlag("server.admin.auth", serverCmd.Flags().Lookup("server-admin-auth"))

View file

@ -21,8 +21,11 @@ type Config struct {
Username string `mapstructure:"username"` Username string `mapstructure:"username"`
} `mapstructure:"admin"` } `mapstructure:"admin"`
Api struct { Api struct {
Auth bool `mapstructure:"auth"` Auth bool `mapstructure:"auth"`
Key string `mapstructure:"key"` Host string `mapstructure:"host"`
Key string `mapstructure:"key"`
Port int `mapstructure:"port"`
Protocol string `mapstructure:"protocol"`
} `mapstructure:"api"` } `mapstructure:"api"`
Documents struct { Documents struct {
AccessKeyId string `mapstructure:"access_key_id"` AccessKeyId string `mapstructure:"access_key_id"`