htmgo/examples/todo-list/main.go
maddalax 10de2f216f Revert "fix example todo"
This reverts commit a2b286e9aa.
2024-09-26 14:40:09 -05:00

39 lines
715 B
Go

package main
import (
"embed"
"github.com/labstack/echo/v4"
"github.com/maddalax/htmgo/framework/h"
"github.com/maddalax/htmgo/framework/service"
_ "github.com/mattn/go-sqlite3"
"io/fs"
"todolist/__htmgo"
"todolist/ent"
"todolist/infrastructure/db"
)
//go:embed assets/dist/*
var StaticAssets embed.FS
func main() {
locator := service.NewLocator()
service.Set[ent.Client](locator, service.Singleton, func() *ent.Client {
return db.Provide()
})
sub, err := fs.Sub(StaticAssets, "assets/dist")
if err != nil {
panic(err)
}
h.Start(h.AppOpts{
ServiceLocator: locator,
LiveReload: true,
Register: func(e *echo.Echo) {
e.StaticFS("/public", sub)
__htmgo.Register(e)
},
})
}