22 lines
563 B
Go
22 lines
563 B
Go
package router
|
|
|
|
import (
|
|
"embed"
|
|
"github.com/gin-contrib/gzip"
|
|
"github.com/gin-contrib/static"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"one-api/common"
|
|
"one-api/middleware"
|
|
)
|
|
|
|
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.Use(static.Serve("/", common.EmbedFolder(buildFS, "web/build")))
|
|
router.NoRoute(func(c *gin.Context) {
|
|
c.Data(http.StatusOK, "text/html; charset=utf-8", indexPage)
|
|
})
|
|
}
|