2025-02-20 08:24:49 +00:00
|
|
|
package redirect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
2025-02-20 11:52:27 +00:00
|
|
|
"fonchain-fiee/pkg/service"
|
2025-02-20 08:24:49 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2025-02-20 08:38:16 +00:00
|
|
|
// ToRedirectRealUrl 重定向到指定位置
|
2025-02-20 08:24:49 +00:00
|
|
|
func ToRedirectRealUrl(c *gin.Context) {
|
|
|
|
|
|
|
|
realUrl := c.Query("base_redirect_url")
|
|
|
|
if realUrl == "" {
|
|
|
|
service.Error(c, errors.New("not real url"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Redirect(http.StatusMovedPermanently, realUrl)
|
|
|
|
}
|
|
|
|
|
2025-02-20 08:38:16 +00:00
|
|
|
// ToRedirectRealUrlAdnRand 重定向到指定位置
|
2025-02-20 08:24:49 +00:00
|
|
|
func ToRedirectRealUrlAdnRand(c *gin.Context) {
|
|
|
|
|
|
|
|
realUrl := c.Query("base_redirect_url")
|
|
|
|
if realUrl == "" {
|
|
|
|
service.Error(c, errors.New("not real url"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-02-20 08:38:16 +00:00
|
|
|
c.Redirect(http.StatusMovedPermanently, realUrl+fmt.Sprintf("?time=%d", time.Now().Unix()))
|
2025-02-20 08:24:49 +00:00
|
|
|
}
|