liuxiaolong
2019-08-16 4c90eaf336a4037f2d497e7b889b2fa21c1a0dd6
middlewares/auth/auth.go
@@ -1,6 +1,7 @@
package auth
import (
   "fmt"
   "github.com/gin-gonic/gin"
   "net/http"
   "strings"
@@ -36,8 +37,18 @@
         c.Next()
      } else if strings.HasPrefix(urlPath,"/httpImage") {
         imgUrl := config.Server.ImageUrl
         idx := strings.Index(urlPath, ":")
         tmpPath := urlPath
         if idx >-1 {//路径中包含有端口,取端口以后路径
            tmpPath = urlPath[idx:]
            imgIndx := strings.Index(imgUrl, ":")
            if imgIndx > -1 {
               imgUrl = imgUrl[:imgIndx-1]
            }
         }
         fmt.Println("imgUrl+tmpPath:", imgUrl+tmpPath)
         c.Header("Access-Control-Allow-Origin","*")
         c.Redirect(http.StatusMovedPermanently, imgUrl+urlPath[10:])
         c.Redirect(http.StatusMovedPermanently, imgUrl+tmpPath)
         return
      } else {
         c.Next()