Skip to content

lwangrabbit/golang-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

/login

curl -X POST http://localhost:9099/login -H "Content-type:application/json" -d '{"username": "admin", "password": "admin"}'

will return token

200
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEwMDEsImV4cCI6MTYzNjEwMTcwNiwiaXNzIjoiVEVTVDAwMSJ9.BFw-E-Pmq5mZ5aRCydIbpJQN6TF6k4618sQXGibi-0g"}

/api/order

curl -X POST http://localhost:9099/api/order -H "Content-type:application/json" -H "token:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEwMDEsImV4cCI6MTYzNjEwMTcwNiwiaXNzIjoiVEVTVDAwMSJ9.BFw-E-Pmq5mZ5aRCydIbpJQN6TF6k4618sQXGibi-0g" -d '{"product": "apple", "count": 3}'

will return response

200
"Hi 1001, I will give you 3 apple"

when give invalid token:

curl -X POST http://localhost:9099/api/order -H "Content-type:application/json" -H "token:xyz" -d '{"product": "apple", "count": 3}'

will return response

403
"Invalid token"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages