(router *gin.Engine, buildFS embed.FS, indexPage []byte)
| 11 | ) |
| 12 | |
| 13 | func SetRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) { |
| 14 | SetApiRouter(router) |
| 15 | SetDashboardRouter(router) |
| 16 | SetRelayRouter(router) |
| 17 | SetVideoRouter(router) |
| 18 | frontendBaseUrl := os.Getenv("FRONTEND_BASE_URL") |
| 19 | if common.IsMasterNode && frontendBaseUrl != "" { |
| 20 | frontendBaseUrl = "" |
| 21 | common.SysLog("FRONTEND_BASE_URL is ignored on master node") |
| 22 | } |
| 23 | if frontendBaseUrl == "" { |
| 24 | SetWebRouter(router, buildFS, indexPage) |
| 25 | } else { |
| 26 | frontendBaseUrl = strings.TrimSuffix(frontendBaseUrl, "/") |
| 27 | router.NoRoute(func(c *gin.Context) { |
| 28 | c.Redirect(http.StatusMovedPermanently, fmt.Sprintf("%s%s", frontendBaseUrl, c.Request.RequestURI)) |
| 29 | }) |
| 30 | } |
| 31 | } |
no test coverage detected