Skip to content

Commit

Permalink
Fix: Cloudflare miss cors header
Browse files Browse the repository at this point in the history
  • Loading branch information
CareyWang committed May 28, 2020
1 parent cdeac8f commit ef1b2ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ func main() {
longUrl := context.PostForm("longUrl")
shortKey := context.PostForm("shortKey")
if longUrl == "" {
res.Code = 0
res.Message = "longUrl为空"
context.JSON(400, *res)
context.JSON(200, *res)
return
}

Expand All @@ -106,8 +107,9 @@ func main() {
// 检测短链是否已存在
_exists, _ := redis.String(redisClient.Do("get", shortKey))
if _exists != "" && _exists != longUrl {
res.Code = 0
res.Message = "短链接已存在,请更换key"
context.JSON(400, *res)
context.JSON(200, *res)
return
}

Expand Down

0 comments on commit ef1b2ef

Please sign in to comment.