iris/_examples/auth/jwt/tutorial
Gerasimos (Makis) Maropoulos a9e808345b
minor
2020-11-04 21:31:15 +02:00
..
api minor 2020-11-04 21:31:15 +02:00
domain add a jwt tutorial + go client 2020-11-04 21:12:13 +02:00
go-client add a jwt tutorial + go client 2020-11-04 21:12:13 +02:00
util add a jwt tutorial + go client 2020-11-04 21:12:13 +02:00
go.mod add a jwt tutorial + go client 2020-11-04 21:12:13 +02:00
main.go add a jwt tutorial + go client 2020-11-04 21:12:13 +02:00
README.md minor 2020-11-04 21:31:15 +02:00

Iris JWT Tutorial

$ go run main.go
$ curl --location --request POST 'http://localhost:8080/signin' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin'

> $token
$ curl --location --request GET 'http://localhost:8080/todos' \
--header 'Authorization: Bearer $token'

> $todos
$ curl --location --request GET 'http://localhost:8080/todos/$id' \
--header 'Authorization: Bearer $token'

> $todo
$ curl --location --request GET 'http://localhost:8080/admin/todos' \
--header 'Authorization: Bearer $token'

> $todos
$ curl --location --request POST 'http://localhost:8080/todos' \
--header 'Authorization: Bearer $token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title": "test titlte",
    "body": "test body"
}'

> Status Created
> $todo

TODO: write the article on https://medium.com/@kataras, https://dev.to/kataras and linkedin first.