From a4b56214b2307f1428ad2d20c62cb9964ce4ad80 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 19 Aug 2023 14:45:07 -0400 Subject: [PATCH 1/2] Documenter NewApiClientFromViper --- api/api.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/api.go b/api/api.go index 42211b6..c6608a3 100644 --- a/api/api.go +++ b/api/api.go @@ -41,6 +41,9 @@ type UploadDocumentResponseInfo struct { Size float64 `json:"size"` } +// 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 NewApiClientFromViper() (*API, error) { var config config.Config From 25aaad42b6c411c06f4704600db0df814db52490 Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Sat, 19 Aug 2023 15:23:10 -0400 Subject: [PATCH 2/2] Utiliser api.NewApiClientFromViper --- cmd/server.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index e37b48f..2b36000 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -441,13 +441,7 @@ func handleAdminDocumentsUploadPOST(c echo.Context) error { Message string } - client, err := api.New(cfg.Server.Api.Protocol, cfg.Server.Api.Host, cfg.Server.Port, api.APIOptions{ - KeyAuth: cfg.Server.Api.Auth, - Key: cfg.Server.Api.Key, - BasicAuth: cfg.Server.Admin.Auth, - Username: cfg.Server.Admin.Username, - Password: cfg.Server.Admin.Password, - }) + client, err := api.NewApiClientFromViper() if err != nil { data.Message = fmt.Sprintf("handleAdminDocumentsUploadPOST#api.New: %s", err) return c.Render(http.StatusInternalServerError, "admin-upload-html", data)