feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -9,7 +9,6 @@ import (
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -21,15 +20,21 @@ type WebAssets struct {
|
||||
|
||||
func SetWebRouter(router *gin.Engine, assets WebAssets, pluginDispatcher gin.HandlerFunc) {
|
||||
frontendFS := common.EmbedFolder(assets.BuildFS, "web/dist")
|
||||
compress := gzip.Gzip(gzip.DefaultCompression)
|
||||
|
||||
router.NoRoute(
|
||||
pluginDispatcher,
|
||||
middleware.RouteTag("web"),
|
||||
gzip.Gzip(gzip.DefaultCompression),
|
||||
func(c *gin.Context) {
|
||||
// ServeFrontendFiles sends build files already compressed.
|
||||
if !frontendFS.Exists("/", c.Request.URL.Path) {
|
||||
compress(c)
|
||||
}
|
||||
},
|
||||
middleware.AccessTokenAudit(),
|
||||
middleware.GlobalWebRateLimit(),
|
||||
middleware.GlobalWebRateLimit(frontendFS),
|
||||
middleware.Cache(),
|
||||
static.Serve("/", frontendFS),
|
||||
middleware.ServeFrontendFiles(frontendFS),
|
||||
func(c *gin.Context) {
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/v1") || strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/assets") {
|
||||
controller.RelayNotFound(c)
|
||||
|
||||
Reference in new issue
Block a user