liuxiaolong
2019-08-16 5ab679ecbe869587da8d93e24a0d5005c359a7d0
middlewares/auth/auth.go
@@ -1,11 +1,11 @@
package auth
import (
   "fmt"
   "github.com/gin-gonic/gin"
   "net/http"
   "strings"
   "webserver/extend/config"
   "webserver/extend/logger"
)
const (
@@ -37,16 +37,17 @@
         c.Next()
      } else if strings.HasPrefix(urlPath,"/httpImage") {
         imgUrl := config.Server.ImageUrl
         urlPath = strings.Replace(urlPath, "/httpImage", "", -1)
         idx := strings.Index(urlPath, ":")
         tmpPath := urlPath
         if idx >-1 {//路径中包含有端口,取端口以后路径
            tmpPath = urlPath[idx:]
            imgIndx := strings.Index(imgUrl, ":")
            imgIndx := strings.LastIndex(imgUrl, ":")
            if imgIndx > -1 {
               imgUrl = imgUrl[:imgIndx-1]
               imgUrl = imgUrl[:imgIndx]
            }
         }
         fmt.Println("imgUrl+tmpPath:", imgUrl+tmpPath)
         logger.Debug("imgUrl+tmpPath:", imgUrl+tmpPath)
         c.Header("Access-Control-Allow-Origin","*")
         c.Redirect(http.StatusMovedPermanently, imgUrl+tmpPath)
         return