2022-07-10 04:02:56 +03:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"io/fs"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
2022-07-15 16:25:29 +03:00
|
|
|
"github.com/labstack/echo/v4/middleware"
|
2022-07-10 04:02:56 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed dist
|
|
|
|
var embeddedFiles embed.FS
|
|
|
|
|
|
|
|
func getFileSystem() http.FileSystem {
|
|
|
|
fs, err := fs.Sub(embeddedFiles, "dist")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return http.FS(fs)
|
|
|
|
}
|
|
|
|
|
|
|
|
func embedFrontend(e *echo.Echo) {
|
2022-07-15 16:25:29 +03:00
|
|
|
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
|
|
|
HTML5: true,
|
|
|
|
Filesystem: getFileSystem(),
|
|
|
|
}))
|
2022-07-10 04:02:56 +03:00
|
|
|
}
|