Made autodeploy pipeline
This commit is contained in:
@@ -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