@@ -21,30 +21,27 @@ Import
21
21
import " github.com/gogf/gf-jwt"
22
22
```
23
23
24
- ## Example
25
-
26
- Check demo [ example/auth/auth.go] ( example/auth/auth.go ) and use ` ExtractClaims ` to customize user data.
27
-
28
- [ embedmd ] :# ( example/auth/auth.go go )
29
-
30
-
31
24
## Demo
32
25
33
- Run ` example/server/server .go ` on the ` 8000 ` port.
26
+ Run ` example/main .go ` on the ` 8000 ` port.
34
27
35
28
``` bash
36
- $ go run example/server/server .go
29
+ $ go run example/main .go
37
30
```
38
31
39
32
![ api screenshot] ( screenshot/server.png )
40
33
41
- Test the effect on the command line via [ httpie] ( https://github.com/jkbrzt/httpie ) .
34
+ Test the effect on the command line via [ httpie] ( https://github.com/jkbrzt/httpie ) or curl .
42
35
43
36
### Login interface:
44
37
45
38
``` bash
46
39
$ http -v --form POST localhost:8000/login username=admin password=admin
47
40
```
41
+ or
42
+ ``` bash
43
+ $ curl -X POST -d ' username=admin&password=admin' localhost:8000/login
44
+ ```
48
45
49
46
Command line output
50
47
@@ -53,19 +50,27 @@ Command line output
53
50
### Refresh token interface:
54
51
55
52
``` bash
56
- $ http -v -f GET localhost:8000/user/refresh_token " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
53
+ $ http -v -f GET localhost:8000/refresh_token " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
54
+ ```
55
+ or
56
+ ``` bash
57
+ $ curl -H ' Authorization:Bearer xxxxxxxxx' -X POST localhost:8000/refresh_token
57
58
```
58
59
59
60
Command line output
60
61
61
62
![ api screenshot] ( screenshot/refresh_token.png )
62
63
63
- ### hello interface
64
+ ### User info interface
64
65
65
- We test the return of the hello interface with the username ` admin ` and password ` admin `
66
+ We test the return of the info interface with the username ` admin ` and password ` admin `
66
67
67
68
``` bash
68
- $ http -f GET localhost:8000/user/hello " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
69
+ $ http -f GET localhost:8000/user/info " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
70
+ ```
71
+ or
72
+ ``` bash
73
+ $ curl -H ' Authorization:Bearer xxxxxx' -X POST localhost:8000/user/info
69
74
```
70
75
71
76
Command line output
@@ -77,12 +82,15 @@ Command line output
77
82
We use an unauthorized token to test the return of the hello interface.
78
83
79
84
``` bash
80
- $ http -f GET localhost:8000/user/hello " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
85
+ $ http -f GET localhost:8000/user/info " Authorization:Bearer xxxxxxxxx" " Content-Type: application/json"
86
+ ```
87
+ or
88
+ ```
89
+ curl -H 'Authorization:Bearer xxxxxx' -X POST localhost:8000/user/info
81
90
```
82
91
83
92
Command line output
84
93
85
94
![ api screenshot] ( screenshot/401.png )
86
95
87
-
88
- Thanks again [ https://github.com/appleboy/gin-jwt ] ( https://github.com/appleboy/gin-jwt )
96
+ Thanks again [ https://github.com/appleboy/gin-jwt ] ( https://github.com/appleboy/gin-jwt )
0 commit comments