36 lines
736 B
Go
36 lines
736 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/maddalax/htmgo/framework/config"
|
|
"github.com/maddalax/htmgo/framework/h"
|
|
"github.com/maddalax/htmgo/framework/service"
|
|
"io/fs"
|
|
"net/http"
|
|
"starter-template/__htmgo"
|
|
)
|
|
|
|
func main() {
|
|
locator := service.NewLocator()
|
|
cfg := config.Get()
|
|
|
|
h.Start(h.AppOpts{
|
|
ServiceLocator: locator,
|
|
LiveReload: true,
|
|
Register: func(app *h.App) {
|
|
sub, err := fs.Sub(GetStaticAssets(), "assets/dist")
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
http.FileServerFS(sub)
|
|
|
|
// change this in htmgo.yml (public_asset_path)
|
|
app.Router.Handle(fmt.Sprintf("%s/*", cfg.PublicAssetPath),
|
|
http.StripPrefix(cfg.PublicAssetPath, http.FileServerFS(sub)))
|
|
|
|
__htmgo.Register(app.Router)
|
|
},
|
|
})
|
|
}
|