Bundle the current backend and web changes into one publishable snapshot from the server worktree so the remote mirror reflects the deployed source. Constraint: Push the existing mixed worktree from /docker/new-api/src without reshaping files Rejected: Split into feature-specific commits | current worktree is already a single undifferentiated snapshot Confidence: medium Scope-risk: moderate Directive: Split future feature work before deployment to preserve clearer history Tested: git status inspection; git diff --stat review Not-tested: build, lint, unit tests, integration tests
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package router
|
|
|
|
import (
|
|
"embed"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/QuantumNous/new-api/common"
|
|
"github.com/QuantumNous/new-api/controller"
|
|
"github.com/QuantumNous/new-api/middleware"
|
|
"github.com/gin-contrib/gzip"
|
|
"github.com/gin-contrib/static"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func SetWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
|
|
router.Use(gzip.Gzip(gzip.DefaultCompression))
|
|
router.Use(middleware.GlobalWebRateLimit())
|
|
router.Use(middleware.Cache())
|
|
router.GET("/image-studio-results/*filepath", controller.GetImageStudioResultFile)
|
|
router.Use(static.Serve("/", common.EmbedFolder(buildFS, "web/dist")))
|
|
router.NoRoute(func(c *gin.Context) {
|
|
c.Set(middleware.RouteTagKey, "web")
|
|
if strings.HasPrefix(c.Request.RequestURI, "/v1") || strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/assets") {
|
|
controller.RelayNotFound(c)
|
|
return
|
|
}
|
|
c.Header("Cache-Control", "no-cache")
|
|
c.Data(http.StatusOK, "text/html; charset=utf-8", indexPage)
|
|
})
|
|
}
|