2023-09-15 13:14:43 -04:00
|
|
|
/*
|
|
|
|
Copyright © 2023 AGECEM & Victor Lacasse-Beaudoin
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-09-15 16:36:56 -04:00
|
|
|
"log"
|
2023-09-15 13:14:43 -04:00
|
|
|
|
2023-09-15 16:36:56 -04:00
|
|
|
"git.agecem.com/agecem/bottin-ag/config"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
"github.com/labstack/echo/v4/middleware"
|
2023-09-15 13:14:43 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
// webCmd represents the web command
|
|
|
|
var webCmd = &cobra.Command{
|
|
|
|
Use: "web",
|
|
|
|
Short: "Start the webserver",
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2023-09-15 16:36:56 -04:00
|
|
|
cfg, err := config.GetConfig()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
e := echo.New()
|
|
|
|
|
|
|
|
e.Pre(middleware.AddTrailingSlash())
|
|
|
|
|
|
|
|
e.Start(fmt.Sprintf(":%d", cfg.Web.Port))
|
2023-09-15 13:14:43 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(webCmd)
|
|
|
|
}
|