rename: Constructeurs client.go pour inclure *APIClient*
This commit is contained in:
parent
469f7c0458
commit
230b4e5db6
2 changed files with 5 additions and 6 deletions
|
@ -17,19 +17,19 @@ type API struct {
|
||||||
Voki *voki.Voki
|
Voki *voki.Voki
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFromViper returns a pointer to a new API object,
|
// NewAPIClientFromViper returns a pointer to a new API object,
|
||||||
// provided the configuration options are managed by
|
// provided the configuration options are managed by
|
||||||
// https://git.agecem.com/agecem/agecem-org/config
|
// https://git.agecem.com/agecem/agecem-org/config
|
||||||
func NewFromViper(client *http.Client) (api *API, err error) {
|
func NewAPIClientFromViper(client *http.Client) (api *API, err error) {
|
||||||
var config Config
|
var config Config
|
||||||
if err = viper.Unmarshal(&config); err != nil {
|
if err = viper.Unmarshal(&config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(client, config.Server.Api.Host, config.Server.Api.Key, config.Server.Api.Port, config.Server.Api.Protocol)
|
return NewAPIClient(client, config.Server.Api.Host, config.Server.Api.Key, config.Server.Api.Port, config.Server.Api.Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(client *http.Client, host, key string, port int, protocol string) (*API, error) {
|
func NewAPIClient(client *http.Client, host, key string, port int, protocol string) (*API, error) {
|
||||||
return &API{Voki: voki.New(client, host, key, port, protocol)}, nil
|
return &API{Voki: voki.New(client, host, key, port, protocol)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
cmd.go
3
cmd.go
|
@ -17,7 +17,6 @@ import (
|
||||||
|
|
||||||
"codeberg.org/vlbeaudoin/pave/v2"
|
"codeberg.org/vlbeaudoin/pave/v2"
|
||||||
"codeberg.org/vlbeaudoin/serpents"
|
"codeberg.org/vlbeaudoin/serpents"
|
||||||
"git.agecem.com/agecem/agecem-org/api"
|
|
||||||
"git.agecem.com/agecem/agecem-org/media"
|
"git.agecem.com/agecem/agecem-org/media"
|
||||||
"git.agecem.com/agecem/agecem-org/public"
|
"git.agecem.com/agecem/agecem-org/public"
|
||||||
"git.agecem.com/agecem/agecem-org/templates"
|
"git.agecem.com/agecem/agecem-org/templates"
|
||||||
|
@ -351,7 +350,7 @@ func RunServer() {
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
defer client.CloseIdleConnections()
|
defer client.CloseIdleConnections()
|
||||||
|
|
||||||
apiClient, err := api.NewFromViper(client)
|
apiClient, err := NewAPIClientFromViper(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue