34 lines
590 B
Go
34 lines
590 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"git.agecem.com/bottin/bottin/v10/pkg/bottin"
|
||
|
"github.com/labstack/echo/v4"
|
||
|
"github.com/labstack/echo/v4/middleware"
|
||
|
)
|
||
|
|
||
|
func RunServer(ctx context.Context, bottinClient *bottin.APIClient) error {
|
||
|
select {
|
||
|
case <-ctx.Done():
|
||
|
return ctx.Err()
|
||
|
default:
|
||
|
if bottinClient == nil {
|
||
|
return fmt.Errorf("nil bottin client")
|
||
|
}
|
||
|
|
||
|
e := echo.New()
|
||
|
|
||
|
e.Renderer = NewRenderer()
|
||
|
|
||
|
e.Pre(middleware.AddTrailingSlash())
|
||
|
|
||
|
e.GET("/", UIIndex(ctx, bottinClient))
|
||
|
|
||
|
e.GET("/membre/", UIReadMembre(ctx, bottinClient))
|
||
|
|
||
|
return e.Start(":3333")
|
||
|
}
|
||
|
}
|