mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00

* chore: standardize context keys with custom ContextKey type * fix bug * 使用Request.Context
34 lines
766 B
Go
34 lines
766 B
Go
package middlewares
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
|
"github.com/OpenListTeam/OpenList/v4/server/common"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func StoragesLoaded(c *gin.Context) {
|
|
if !conf.StoragesLoaded {
|
|
if utils.SliceContains([]string{"", "/", "/favicon.ico"}, c.Request.URL.Path) {
|
|
c.Next()
|
|
return
|
|
}
|
|
paths := []string{"/assets", "/images", "/streamer", "/static"}
|
|
for _, path := range paths {
|
|
if strings.HasPrefix(c.Request.URL.Path, path) {
|
|
c.Next()
|
|
return
|
|
}
|
|
}
|
|
common.ErrorStrResp(c, "Loading storage, please wait", 500)
|
|
c.Abort()
|
|
return
|
|
}
|
|
common.GinWithValue(c,
|
|
conf.ApiUrlKey, common.GetApiUrlFromRequest(c.Request),
|
|
)
|
|
c.Next()
|
|
}
|