package main import ( "errors" "flag" "fmt" "log" "net/http" "text/template" rice "github.com/GeertJohan/go.rice" "github.com/go-playground/validator" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "gitnet.fr/deblan/owncast-webhook/internal/client/twitch" "gitnet.fr/deblan/owncast-webhook/internal/config" "gitnet.fr/deblan/owncast-webhook/internal/web/router" ) type TemplateRenderer struct { templates *template.Template } type AppValidator struct { validator *validator.Validate } func (cv *AppValidator) Validate(i interface{}) error { return cv.validator.Struct(i) } func main() { ini := flag.String("c", "config.ini", "Path to config.ini") conf := config.Get() conf.Load(*ini) e := echo.New() e.Validator = &AppValidator{validator: validator.New()} e.Static("/dist", "dist") assetHandler := http.FileServer(rice.MustFindBox("../../assets/dist").HTTPBox()) e.GET("/dist/*", echo.WrapHandler(http.StripPrefix("/dist/", assetHandler))) e.Use(middleware.Logger()) router.RegisterControllers(e) if conf.Twitch.Enable { twitch.IrcClient() } if err := e.Start(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port)); err != nil && !errors.Is(err, http.ErrServerClosed) { log.Fatal(err) } }