O Projeto criado para controle cadastros de planetas.
Realizar o cadastros de planetas e consultar a quantidade de vezes que o mesmo aparece no filme Star Wars.
PORT=5000
SWAPI_BASE_URL=https://swapi.dev/api
MONGO_URI=mongodb://localhost:27017
MONGO_DATABASE=planetsDB
go run .\main.go
Exemplos de Requisições para a API
GET /planets/
curl -i -H 'Accept: application/json' http://localhost:5000/planets/
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2
[
{
"id": "6189b9011f3c71cea77710e8",
"name": "Tatooine",
"climate": "Arid",
"terrain": "Desert",
"viewed_quantity": 0
}
]
GET /planets/?search=Tatooine
curl -i -H 'Accept: application/json' \
http://localhost:5000/planets?search=Tatooine
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 09 Nov 2021 13:53:56 GMT
Content-Length: 21
[
{
"id": "6189b9011f3c71cea77710e8",
"name": "Tatooine",
"climate": "Arid",
"terrain": "Desert",
"viewed_quantity": 0
}
]
POST /planets/
curl -i -H 'Content-Type: application/json' \
-X POST \
-d '{"name": "Tatooine","Climate": "Arid","Terrain": "Desert"}' \
http://localhost:5000/planets/
HTTP/1.1 201 Created
Content-Type: application/json
Date: Tue, 09 Nov 2021 13:53:56 GMT
Content-Length: 21
{
"id": "618a7c0cfc27011a4ae8a1e9",
"name": "Tatooine",
"climate": "Arid",
"terrain": "Desert",
"viewed_quantity": 5
}
PUT /planets/
curl -i -H 'Content-Type: application/json' \
-X PUT \
-d '{"id": "618a7c0cfc27011a4ae8a1e9", "name": "Tatooine","Climate": "Arid","Terrain": "Desert"}' \
http://localhost:5000/planets/618a7c0cfc27011a4ae8a1e9
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 09 Nov 2021 13:53:56 GMT
Content-Length: 21
DELETE /planets/
curl -i -H 'Content-Type: application/json' \
-X DELETE \
http://localhost:5000/planets/618a7c0cfc27011a4ae8a1e9
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 09 Nov 2021 13:53:56 GMT
Content-Length: 21
- Golang versão 1.17 ou superior
- Colocar o consumo da SWAPI como Assincrona
- Incrementar mais Testes(Repositorios, Modelos e etc...)