Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
demo-go
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭芳
demo-go
Commits
32c58e20
Commit
32c58e20
authored
Feb 22, 2023
by
彭芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[minor]: add InvalidAccessToken err
parent
0a1add5b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
error.go
internal/biz/errs/error.go
+3
-2
Jwt.go
internal/router/mid/Jwt.go
+3
-2
web.go
internal/router/web.go
+1
-1
No files found.
internal/biz/errs/error.go
View file @
32c58e20
...
...
@@ -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
{
...
...
internal/router/mid/Jwt.go
View file @
32c58e20
...
...
@@ -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
}
...
...
internal/router/web.go
View file @
32c58e20
...
...
@@ -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"
,
"m
sg
"
:
"PageNo not found"
})
c
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"code"
:
"404"
,
"m
essage
"
:
"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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment