feat: refactor code structure

This commit is contained in:
Steven
2023-02-23 08:22:06 +08:00
parent f77a84a649
commit 0fbbcae872
36 changed files with 768 additions and 936 deletions

View File

@@ -5,7 +5,6 @@ import (
"io/fs"
"net/http"
"github.com/boojack/corgi/common"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
@@ -22,16 +21,11 @@ func getFileSystem(path string) http.FileSystem {
return http.FS(fs)
}
func skipper(c echo.Context) bool {
path := c.Path()
return common.HasPrefixes(path, "/api", "/o")
}
func embedFrontend(e *echo.Echo) {
// Use echo static middleware to serve the built dist folder
// refer: https://github.com/labstack/echo/blob/master/middleware/static.go
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Skipper: skipper,
Skipper: defaultAPIRequestSkipper,
HTML5: true,
Filesystem: getFileSystem("dist"),
}))
@@ -44,7 +38,7 @@ func embedFrontend(e *echo.Echo) {
}
})
g.Use(middleware.StaticWithConfig(middleware.StaticConfig{
Skipper: skipper,
Skipper: defaultAPIRequestSkipper,
HTML5: true,
Filesystem: getFileSystem("dist/assets"),
}))