1g

func (a *ShortUrlController) QueryUrlLong(c *gin.Context) {
    short := c.Param("short")
    status, msg := biz.QueryUrlByKey(short)
    if status == 0 {
        //如果存在原始url 直接重定向到新地址 实现短链接功能
        c.Redirect(http.StatusMovedPermanently, msg)
    } else {
        //不存在则返回具体信息
        c.JSONP(http.StatusOK, gin.H{
            "status": status,
            "msg":    msg,
        })
    }

}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code