https://github.com/augustoscher/go-api-c
GOlang API with JWT authentication example
https://github.com/augustoscher/go-api-c
api-rest go golang jwt
Last synced: about 1 month ago
JSON representation
GOlang API with JWT authentication example
- Host: GitHub
- URL: https://github.com/augustoscher/go-api-c
- Owner: augustoscher
- Created: 2019-05-16T13:46:49.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-16T14:09:40.000Z (about 7 years ago)
- Last Synced: 2025-12-30T11:39:27.196Z (6 months ago)
- Topics: api-rest, go, golang, jwt
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-api-c #
#### GOlang API with JWT authentication example ####
* GOlang-API-C
##### Requirements:
- Go needs to be installed.
- Some tool to endpoint testing (curl, postman)
### Setting Up
----
##### 1. Clone the repositorie in your GOPATH
> git clone https://augustoscher@bitbucket.org/augustoscher/api-c.git
##### 2. Access the repositorie
> cd go-api-c
##### 3. Install the dependencies
> go get
or one by one
> got get github.com/codegangsta/negroni
> got get github.com/dgrijalva/jwt-go
> got get github.com/gorilla/context
> got get github.com/gorilla/mux
> got get github.com/mitchellh/mapstructure
##### 4. Running
> go run main.go
### Test
----
##### 1. Login
> POST http://localhost:3000/login
```json
{
"username": "augusto",
"password": "testing"
}
```
It should return:
```json
{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InRlc3RpbmciLCJ1c2VybmFtZSI6ImF1Z3VzdG8ifQ.77xiMA_tBkEhwigv9n5iAk_i59Y63eRLWuk3AehARO8"}
```
You have to add Bearer Token in header of every request.
##### 2. Get the history of searchs by CPF
> GET http://localhost:3000/consultascpf/02206795012
or
> http://localhost:3000/consultascpf
##### 3. Get the history of financial transactions by CPF
> GET http://localhost:3000/movimentosfinanceiro/02506196013
or
> GET http://localhost:3000/movimentosfinanceiro
##### 4. Get the history of credit card transactions by CPF
> GET http://localhost:3000/movimentoscartao/02506196013
or
> A url http://localhost:3000/movimentoscartao
### Next steps
----
Dockerize the API and HTTP Rest Client with docker-compose