Refactor du projet réduire le nombre de packages et sous-dossiers #200

Merged
vlbeaudoin merged 15 commits from vlbeaudoin/rework/single-package into main 2024-08-22 13:42:33 -04:00 AGit
2 changed files with 5 additions and 6 deletions
Showing only changes of commit 230b4e5db6 - Show all commits

View file

@ -17,19 +17,19 @@ type API struct {
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
// 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
if err = viper.Unmarshal(&config); err != nil {
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
}

3
cmd.go
View file

@ -17,7 +17,6 @@ import (
"codeberg.org/vlbeaudoin/pave/v2"
"codeberg.org/vlbeaudoin/serpents"
"git.agecem.com/agecem/agecem-org/api"
"git.agecem.com/agecem/agecem-org/media"
"git.agecem.com/agecem/agecem-org/public"
"git.agecem.com/agecem/agecem-org/templates"
@ -351,7 +350,7 @@ func RunServer() {
client := http.DefaultClient
defer client.CloseIdleConnections()
apiClient, err := api.NewFromViper(client)
apiClient, err := NewAPIClientFromViper(client)
if err != nil {
log.Fatal(err)
}