31 lines
624 B
Cheetah
31 lines
624 B
Cheetah
package route
|
|
|
|
import (
|
|
"{{ .Name }}/route/api"
|
|
"embed"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/echo/v4/middleware"
|
|
|
|
_ "{{ .Name }}/docs"
|
|
|
|
echoSwagger "github.com/swaggo/echo-swagger"
|
|
)
|
|
|
|
//go:embed static
|
|
var content embed.FS
|
|
|
|
func Init(e *echo.Echo) {
|
|
|
|
e.GET("/swagger/*", echoSwagger.WrapHandler)
|
|
|
|
api.Init(e.Group("/api"))
|
|
|
|
var contentHandler = echo.WrapHandler(http.FileServer(http.FS(content)))
|
|
var contentRewrite = middleware.Rewrite(map[string]string{"/*": "/static/$1"})
|
|
//e.GET("/", main)
|
|
e.GET("/*", contentHandler, contentRewrite)
|
|
e.GET("*", contentHandler, contentRewrite)
|
|
}
|