mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 00:56:37 +08:00
[重构] 清除旧兼容层
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"atsflare/controller"
|
||||
"atsflare/middleware"
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/gin-contrib/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/fs"
|
||||
@@ -23,7 +22,6 @@ func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
|
||||
router.Use(middleware.GlobalWebRateLimit())
|
||||
fileDownloadRoute := router.Group("/")
|
||||
fileDownloadRoute.GET("/upload/:file", middleware.DownloadRateLimit(), controller.DownloadFile)
|
||||
registerLegacyWebRedirects(router)
|
||||
router.Use(middleware.Cache())
|
||||
router.Use(static.Serve("/", common.EmbedFolder(buildFS, "web/build")))
|
||||
router.NoRoute(func(c *gin.Context) {
|
||||
@@ -40,35 +38,6 @@ func setWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
|
||||
})
|
||||
}
|
||||
|
||||
func registerLegacyWebRedirects(router *gin.Engine) {
|
||||
legacyRoutes := map[string]string{
|
||||
"/proxy-route": "/proxy-routes",
|
||||
"/config-version": "/config-versions",
|
||||
"/node": "/nodes",
|
||||
"/apply-log": "/apply-logs",
|
||||
"/managed-domain": "/managed-domains",
|
||||
"/tls-certificate": "/tls-certificates",
|
||||
"/file": "/files",
|
||||
"/user": "/users",
|
||||
"/user/add": "/users?mode=create",
|
||||
"/user/edit": "/users",
|
||||
"/setting": "/settings",
|
||||
}
|
||||
|
||||
for source, target := range legacyRoutes {
|
||||
router.GET(source, func(target string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Redirect(http.StatusFound, target)
|
||||
}
|
||||
}(target))
|
||||
}
|
||||
|
||||
router.GET("/user/edit/:id", func(c *gin.Context) {
|
||||
target := fmt.Sprintf("/users?edit=%s", c.Param("id"))
|
||||
c.Redirect(http.StatusFound, target)
|
||||
})
|
||||
}
|
||||
|
||||
func serveExportedPage(c *gin.Context, buildFS fs.FS) bool {
|
||||
requestPath := strings.Trim(c.Request.URL.Path, "/")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user