Migrate webclient to voki and add webhandlers.Handler

This commit is contained in:
Victor Lacasse-Beaudoin 2023-09-18 22:07:02 -04:00
parent 6dff76d871
commit ad83bc081a
2 changed files with 16 additions and 7 deletions

View file

@ -7,6 +7,7 @@ import (
"html/template"
"io"
"log"
"net/http"
"git.agecem.com/agecem/bottin/v5/data"
"git.agecem.com/agecem/bottin/v5/web"
@ -53,7 +54,10 @@ var webCmd = &cobra.Command{
// Ping API server
apiClient := data.NewApiClient(webApiKey, webApiHost, webApiProtocol, webApiPort)
client := http.DefaultClient
defer client.CloseIdleConnections()
apiClient := data.NewApiClient(client, webApiKey, webApiHost, webApiProtocol, webApiPort)
pingResult, err := apiClient.GetHealth()
if err != nil {
@ -84,8 +88,10 @@ var webCmd = &cobra.Command{
// Routes
e.GET("/", webhandlers.GetIndex)
e.GET("/membre/", webhandlers.GetMembre)
handler := webhandlers.Handler{APIClient: apiClient}
e.GET("/", handler.GetIndex)
e.GET("/membre/", handler.GetMembre)
// Execution