https://api-rest-spring-docker.herokuapp.com/api/customers
- Download Docker Here. Hint: Enable Hyper-V feature on windows and restart;
- Then open powershell and check:
docker info
or check docker version
docker -v
or docker compose version
docker-compose -v
- Clone the repository:
git clone https://github.com/JoaoVictorArruda/api-rest.git
- Build the maven project:
mvn clean install
- Running the containers:
This command will build the docker containers and start them.
docker-compose up
or
This is a similar command as above, except it will run all the processes in the background.
docker-compose -f docker-compose.yml up
All commands should be run from project root (where docker-compose.yml locates)
- If you have to want to see running containers. Checklist docker containers
docker container list -a
or
docker-compose ps
- Check all the images you have:
docker images
- Stop containers:
docker-compose down
- Remove old stopped containers of docker-compose
docker-compose rm -f
GET /api/customers/
curl -i -H 'Accept: application/json' http://localhost:8080/api/customers
HTTP/1.1 200 OK
Date: Wed, 18 Aug 2021 20:15:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2
[
{
"createdAt": "2021-08-18T12:23:33.247+00:00",
"updatedAt": "2021-08-18T12:23:33.247+00:00",
"id": 5,
"name": "João",
"cpf": "058.457.547-44",
"address": "Longview Road"
},
]
POST /api/customers/:id
curl -i -X POST -H "Content-Type: application/json" -d "{\"name\":\"Joao\", \"cpf\":\"452.785.452-75\", \"address\":\"Forest Road\"}" http://localhost:8080/api/customers/
HTTP/1.1 201 Created
Date: Wed, 18 Aug 2021 20:16:54 GMT
Status: 201 Created
Connection: close
Content-Type: application/json
{"createdAt": "2021-08-18T12:23:33.247+00:00", "updatedAt": "2021-08-18T20:16:54.247+00:00", "id": 1, "name": "João", "cpf": "452.785.452-75", "address": "Forest Road"}
GET /api/customers/:id
curl -i -H 'Accept: application/json' http://localhost:8080/api/customers/1
HTTP/1.1 200 OK
Date: Wed, 18 Aug 2021 20:31:31 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
{"createdAt": "2021-08-18T12:23:33.247+00:00", "updatedAt": "2021-08-18T20:16:54.247+00:00", "id": 1, "name": "João", "cpf": "452.785.452-75", "address": "Forest Road"}
GET api/customers/id
curl -i -H 'Accept: application/json' http://localhost:8080/api/customers/9999
HTTP/1.1 404 Not Found
Date: Wed, 18 Aug 2021 20:31:31 GMT
Status: 404 Not Found
Connection: close
Content-Type: application/json
{"timestamp":"2021-08-18T20:31:24.048+00:00","status":404,"error":"Not Found","message":"","path":"/api/customers/9999"}
PUT /api/customers/:id
curl -i -X PUT -H "Content-Type: application/json" -d "{\"name\":\"Joao Arruda\", \"cpf\":\"854.524.699-22\", \"address\":\"Street Road\"}" http://localhost:8080/api/customers/1
HTTP/1.1 200 OK
Date: Wed, 18 Aug 2021 20:18:04 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
{"createdAt":"2021-08-18T20:17:31.845+00:00","updatedAt":"2021-08-18T20:18:04.845+00:00","id":1,"name":"Joao Arruda","cpf":"854.524.699-22","address":"Street Road"}
DELETE /api/customers/:id
curl -i -H 'Accept: application/json' -X DELETE http://localhost:8080/api/customers/1
HTTP/1.1 204 No Content
Date: Wed, 18 Aug 2021 20:25:54 GMT
Status: 204 No Content
Connection: close
DELETE /api/customers/:id
curl -i -H 'Accept: application/json' -X DELETE http://localhost:8080/api/customers/1/
HTTP/1.1 404 Not Found
Date: Wed, 18 Aug 2021 20:25:59 GMT
Status: 404 Not Found
Connection: close
Content-Type: application/json
{"timestamp":"2021-08-18T20:25:54.700+00:00","status":404,"error":"Not Found","message":"","path":"/api/customers/1"}