Ajouter data.NewApiClientFromViper()
This commit is contained in:
parent
098d255190
commit
4673612e06
1 changed files with 10 additions and 0 deletions
|
@ -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,
|
||||
|
|
Reference in a new issue