MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / SetWebRouter

Function SetWebRouter

router/web-router.go:15–28  ·  view source on GitHub ↗
(router *gin.Engine, buildFS embed.FS, indexPage []byte)

Source from the content-addressed store, hash-verified

13)
14
15func SetWebRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
16 router.Use(gzip.Gzip(gzip.DefaultCompression))
17 router.Use(middleware.GlobalWebRateLimit())
18 router.Use(middleware.Cache())
19 router.Use(static.Serve("/", common.EmbedFolder(buildFS, "web/dist")))
20 router.NoRoute(func(c *gin.Context) {
21 if strings.HasPrefix(c.Request.RequestURI, "/v1") || strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/assets") {
22 controller.RelayNotFound(c)
23 return
24 }
25 c.Header("Cache-Control", "no-cache")
26 c.Data(http.StatusOK, "text/html; charset=utf-8", indexPage)
27 })
28}

Callers 1

SetRouterFunction · 0.85

Calls 4

GlobalWebRateLimitFunction · 0.92
CacheFunction · 0.92
EmbedFolderFunction · 0.92
RelayNotFoundFunction · 0.92

Tested by

no test coverage detected