frontend.go raw

   1  package frontend
   2  
   3  import (
   4  	"embed"
   5  	"net/http"
   6  
   7  	"github.com/labstack/echo/v4"
   8  	"github.com/labstack/echo/v4/middleware"
   9  )
  10  
  11  //go:embed dist
  12  var embeddedReactAssets embed.FS
  13  
  14  func RegisterHandlers(e *echo.Echo) {
  15  	e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
  16  		Skipper: nil,
  17  		// Root directory from where the static content is served.
  18  		Root: "dist",
  19  		// Enable HTML5 mode by forwarding all not-found requests to root so that
  20  		// SPA (single-page application) can handle the routing.
  21  		HTML5:      true,
  22  		Browse:     false,
  23  		IgnoreBase: false,
  24  		Filesystem: http.FS(embeddedReactAssets),
  25  	}))
  26  }
  27