agendas/server.go

44 lines
895 B
Go
Raw Normal View History

2024-12-23 20:57:58 -05:00
package main
import (
"context"
"fmt"
2024-12-30 15:00:42 -05:00
"git.agecem.com/bottin/agendas/ui"
2024-12-23 20:57:58 -05:00
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
2024-12-30 15:00:42 -05:00
func RunServer(ctx context.Context, cfg Config, bottinClient *bottin.APIClient, dbClient *DBClient) error {
2024-12-23 20:57:58 -05:00
select {
case <-ctx.Done():
return ctx.Err()
default:
if bottinClient == nil {
return fmt.Errorf("nil bottin client")
}
2024-12-30 15:00:42 -05:00
if dbClient == nil {
return fmt.Errorf("nil dbClient")
}
2024-12-23 20:57:58 -05:00
e := echo.New()
2024-12-30 15:00:42 -05:00
e.Renderer = ui.NewRenderer()
2024-12-23 20:57:58 -05:00
e.Pre(middleware.AddTrailingSlash())
2024-12-30 15:00:42 -05:00
//basicauth TODO
//e.Use(
e.GET("/", UIIndex(ctx, bottinClient, dbClient))
//e.GET("/transaction/", UIReadTransaction
e.POST("/transaction/", UICreateTransaction(ctx, cfg, bottinClient, dbClient))
2024-12-23 20:57:58 -05:00
2024-12-30 15:00:42 -05:00
//e.GET("/membre/", UIReadMembre(ctx, bottinClient))
2024-12-23 20:57:58 -05:00
return e.Start(":3333")
}
}