Made autodeploy pipeline
This commit is contained in:
@@ -128,6 +128,8 @@ func NewServer(cfg config.Config) *Server {
|
||||
authRouter := routers.NewAuthRouter(authService)
|
||||
authRouter.RegisterRouter(apiV1)
|
||||
|
||||
// подключаем статику Vue — должно быть последним
|
||||
registerStaticFiles(router)
|
||||
return &Server{
|
||||
httpServer: &http.Server{
|
||||
Addr: cfg.APIHost + ":" + cfg.APIPort,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
//go:embed dist
|
||||
var staticFiles embed.FS
|
||||
|
||||
func registerStaticFiles(router *gin.Engine) {
|
||||
// вырезаем префикс dist/ чтобы / отдавал index.html
|
||||
distFS, err := fs.Sub(staticFiles, "dist")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fileServer := http.FileServer(http.FS(distFS))
|
||||
|
||||
// все маршруты которые не /api и не /openapi — отдаём Vue
|
||||
router.NoRoute(func(c *gin.Context) {
|
||||
fileServer.ServeHTTP(c.Writer, c.Request)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user