|
|
|
@ -3,9 +3,11 @@ package middleware
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
model "github.com/cloudreve/Cloudreve/v3/models"
|
|
|
|
|
"github.com/cloudreve/Cloudreve/v3/pkg/auth"
|
|
|
|
|
"github.com/cloudreve/Cloudreve/v3/pkg/hashid"
|
|
|
|
|
"github.com/cloudreve/Cloudreve/v3/pkg/serializer"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// HashID 将给定对象的HashID转换为真实ID
|
|
|
|
@ -60,3 +62,16 @@ func StaticResourceCache() gin.HandlerFunc {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MobileRequestOnly
|
|
|
|
|
func MobileRequestOnly() gin.HandlerFunc {
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
if c.GetHeader(auth.CrHeaderPrefix+"ios") == "" {
|
|
|
|
|
c.Redirect(http.StatusMovedPermanently, model.GetSiteURL().String())
|
|
|
|
|
c.Abort()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.Next()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|