Commit 32c58e20 by 彭芳

[minor]: add InvalidAccessToken err

parent 0a1add5b
......@@ -3,8 +3,9 @@ package errs
import "fmt"
var (
ErrorArgs = New(40001, "请求参数错误")
ServiceError = New(50000, "系统错误请稍后再试。")
ErrorArgs = New(40001, "请求参数错误")
InvalidAccessToken = New(40105, "access token错误")
ServiceError = New(50000, "系统错误请稍后再试。")
)
type Error struct {
......
......@@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"demo/internal/biz/errs"
"demo/internal/util"
)
......@@ -16,8 +17,8 @@ func (p *Jwt) CheckToken(c *gin.Context) {
if util.DefaultToken != headerToken {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
util.RequestKey: c.GetString(util.RequestKey),
"code": http.StatusUnauthorized,
"message": "token 校验失败",
"code": errs.InvalidAccessToken.Code,
"message": errs.InvalidAccessToken.Msg,
})
return
}
......
......@@ -20,7 +20,7 @@ type Web struct {
func (p *Web) RouterInit(engine *gin.Engine) {
engine.Use(p.Common.SetRequestId, p.Common.PassMethods)
engine.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{"code": "404", "msg": "PageNo not found"})
c.JSON(http.StatusNotFound, gin.H{"code": "404", "message": "PageNo not found"})
})
// add pprof to look at the heap,a 30-second CPU and so on profile
// eg: go tool pprof http://localhost:8000/api/pprof/profile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment