Commit 6a55735f authored by David PETIT's avatar David PETIT
Browse files

Update README.md

parent 995c6ba1
# REST-API-GO
# API-Rest-Visualisation
The security of the api is based on Gin-JWT.
The connector of cozy sends the doctype information to the API. https://github.com/Debzou/cozy-konnector-output
Then this API allows the visualization of energy consumption on a map.
# Launch
## Start API in container :whale:
......@@ -68,6 +72,7 @@ Routes Protected
```sh
[GIN-debug] GET /auth/refresh_token --> github.com/appleboy/gin-jwt/v2.(*GinJWTMiddleware).RefreshHandler-fm (3 handlers)
[GIN-debug] GET /auth/hello --> github.com/Debzou/REST-API-GO/internal/controllers.HelloHandler (4 handlers)
[GIN-debug] POST /auth/consumption --> github.com/Debzou/REST-API-GO/internal/controllers.PostConsumption (4 handlers)
```
Login / Signup
......@@ -75,3 +80,86 @@ Login / Signup
[GIN-debug] POST /signup --> github.com/Debzou/REST-API-GO/internal/controllers.CreateUser (3 handlers)
[GIN-debug] POST /login --> github.com/appleboy/gin-jwt/v2.(*GinJWTMiddleware).LoginHandler-fm (3 handlers)
```
## Exemple POST http/Curl
### POST /signup
```http
POST /signup HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"username" : "debzou",
"password" : "debzou",
}
```
Using Curl
```sh
curl --location --request POST 'localhost:8080/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
"username" : "debzou",
"password" : "debzou",
}'
```
### POST /login
```http
POST /login HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"password":"adminAAAaakkkk",
"username":"admin55kkklll"
}
```
Using Curl
```sh
curl --location --request POST 'localhost:8080/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"password":"adminAAAaakkkk",
"username":"admin55kkklll"
}'
```
### POST /auth/consumption
```http
POST /auth/consumption HTTP/1.1
Host: localhost:8080
Authorization: Bearer yourtoken
Content-Type: application/json
{
"pseudo": "test",
"latitude": 55.5,
"longitude": 10.6,
"averagedailyconsumption": 3000.0,
"averagemonthlyconsumption": 500.5,
"averageannualconsumption": 600.0
}
```
Using Curl
```sh
curl --location --request POST 'localhost:8080/auth/consumption' \
--header 'Authorization: Bearer yourtoken \
--header 'Content-Type: application/json' \
--data-raw '{
"pseudo": "test",
"latitude": 55.5,
"longitude": 10.6,
"averagedailyconsumption": 3000.0,
"averagemonthlyconsumption": 500.5,
"averageannualconsumption": 600.0
}'
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment