修复:weblive 协程 panic 防护、Mongo 空指针防护、直播状态轮询退避
Made-with: Cursor
This commit is contained in:
@@ -47,6 +47,11 @@ func GetWebHomepage(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if config.MongoClient == nil {
|
||||
c.JSON(http.StatusOK, defaultHomepageData())
|
||||
return
|
||||
}
|
||||
|
||||
siteID := getOfficialSiteID(ctx)
|
||||
if siteID == "" {
|
||||
c.JSON(http.StatusOK, defaultHomepageData())
|
||||
|
||||
@@ -35,6 +35,11 @@ func GetWebRoutes(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if config.MongoClient == nil {
|
||||
c.JSON(http.StatusOK, gin.H{"site_id": "", "routes": []any{}})
|
||||
return
|
||||
}
|
||||
|
||||
siteID := c.Query("site_id")
|
||||
if siteID == "" {
|
||||
siteID = getOfficialSiteID(ctx)
|
||||
@@ -84,6 +89,11 @@ func GetWebPageByPath(c *gin.Context) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if config.MongoClient == nil {
|
||||
c.JSON(http.StatusServiceUnavailable, gin.H{"error": "服务暂不可用"})
|
||||
return
|
||||
}
|
||||
|
||||
siteID := c.Query("site_id")
|
||||
if siteID == "" {
|
||||
siteID = getOfficialSiteID(ctx)
|
||||
|
||||
Reference in New Issue
Block a user