Ajouter et implémenter cfg.Bottin.API.Key

This commit is contained in:
Victor Lacasse-Beaudoin 2023-09-16 18:18:19 -04:00
parent ea49f1609f
commit 9b6dd055ef
2 changed files with 8 additions and 1 deletions

View file

@ -32,7 +32,7 @@ var apiCmd = &cobra.Command{
v0 := e.Group("/v0") v0 := e.Group("/v0")
bottinApiClient := bottindata.NewApiClient("bottin", cfg.Bottin.API.Host, "http", 1312) bottinApiClient := bottindata.NewApiClient(cfg.Bottin.API.Key, cfg.Bottin.API.Host, "http", 1312)
dbClient, err := dbclient.New("db", "bottinag", "bottinag", "bottinag", 5432, false) dbClient, err := dbclient.New("db", "bottinag", "bottinag", "bottinag", 5432, false)
if err != nil { if err != nil {

View file

@ -22,6 +22,7 @@ type APIConfig struct {
type BottinConfig struct { type BottinConfig struct {
API struct { API struct {
Host string Host string
Key string
} }
} }
@ -69,6 +70,12 @@ func RegisterFlags(cmd *cobra.Command) error {
return err return err
} }
// bottin.api.key
if err := RegisterString(cmd, true,
"bottin.api.key", "bottin-api-key", "Bottin API server key", "bottin"); err != nil {
return err
}
// web.port ; --web-port // web.port ; --web-port
cmd.PersistentFlags().Int("web-port", 3183, "Webserver port") cmd.PersistentFlags().Int("web-port", 3183, "Webserver port")
if err := viper.BindPFlag("web.port", cmd.PersistentFlags().Lookup("web-port")); err != nil { if err := viper.BindPFlag("web.port", cmd.PersistentFlags().Lookup("web-port")); err != nil {