| 123456789101112131415161718192021 |
- package handler
- import (
- "os"
- "path/filepath"
- "github.com/labstack/echo/v4"
- )
- func RegisterFrontend(e *echo.Echo, distPath string) {
- e.GET("/*", func(c echo.Context) error {
- path := c.Request().URL.Path
- filePath := filepath.Join(distPath, path)
- if _, err := os.Stat(filePath); err != nil {
- return c.File(filepath.Join(distPath, "index.html"))
- }
- return c.File(filePath)
- })
- }
|