mirror of
https://github.com/usememos/memos.git
synced 2024-12-28 16:14:03 +08:00
29 lines
467 B
Go
29 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(),
|
|
}))
|
|
}
|