From 4673612e06ef8e6a546181c978972f939bf40a60 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Fri, 2 Jun 2023 02:43:37 -0400 Subject: [PATCH] Ajouter data.NewApiClientFromViper() --- data/apiclient.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/data/apiclient.go b/data/apiclient.go index f97684b..9fc1d5a 100644 --- a/data/apiclient.go +++ b/data/apiclient.go @@ -9,6 +9,7 @@ import ( "net/http" "git.agecem.com/agecem/bottin/v4/models" + "github.com/spf13/viper" ) type ApiClient struct { @@ -18,6 +19,15 @@ type ApiClient struct { Protocol string } +func NewApiClientFromViper() *ApiClient { + apiClientKey := viper.GetString("web.api.key") + apiClientHost := viper.GetString("web.api.host") + apiClientProtocol := viper.GetString("web.api.protocol") + apiClientPort := viper.GetInt("web.api.port") + + return NewApiClient(apiClientKey, apiClientHost, apiClientProtocol, apiClientPort) +} + func NewApiClient(key, host, protocol string, port int) *ApiClient { return &ApiClient{ Key: key,