mirror of
https://github.com/usememos/memos.git
synced 2024-12-19 00:51:30 +03:00
30 lines
467 B
Go
30 lines
467 B
Go
package server
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/echo/v4/middleware"
|
|
)
|
|
|
|
//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) {
|
|
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
|
HTML5: true,
|
|
Filesystem: getFileSystem(),
|
|
}))
|
|
}
|