mirror of https://github.com/usememos/memos
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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(),
|
|
}))
|
|
}
|