About | Features | Technologies | Requirements | Starting | Containerization | License | Author
This API is a simple todo list. It is a RESTful API that allows you to create, read, update and delete todos.
Parameter | Type | Description |
---|---|---|
id |
string |
The id of the todo object |
title |
string |
The title of the todo object |
✔️ List todos
✔️ Get todo status
✔️ Create a new todo object
✔️ Delete a todo object
The following tools were used in this project:
- Go: The language used in this project
- Docker: The containerization tool used in this project
- GitHub: The source control tool used in this project
- GitHub Actions: The continuous integration tool used in this project
Before starting 🏁, you need to have Git, Docker, and Go installed.
- Clone the project
git clone https://github.com/devenes/todos-api
- Go to the project directory:
cd todos-api
- Run the following command to start the server:
go run main.go
- You can also run the server in the background:
go run main.go &
- Build the Docker image:
docker build -t devenes/todos-api:1 ./
- You can also run the server in a Docker container:
docker run -p 8080:8080 -d devenes/todos-api:1
- See the output:
docker build -t devenes/todos-api:1 ./ && docker run -p 8080:8080 -d devenes/todos-api:1 && explorer "http://localhost:8080/todos"
- List todos with the following command:
curl http://localhost:8080/todos
- Get the first todo with the following command:
curl http://localhost:8080/todos/1
- Create a new todo with the following command:
curl -X POST -H 'content-type: application/json' --data '{"id": "4", "title": "Buy milk"}' http://localhost:8080/todos
- Update the first todo with the following command:
curl -X POST -H 'content-type: application/json' --data '{"id": "1", "title": "Check the mailbox"}' http://localhost:8080/todos
- Delete the first todo with the following command:
curl -X DELETE http://localhost:8080/todos/1
- Get the second todo with the following command:
curl http://localhost:8080/todos/2
- Stop and remove all Docker containers and images:
docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q)
You can reduce the size of the Docker image from 301MB to 12MB by using multi-stage containerization. Check the Dockerfile to see how it works and look at the latest image created with alpine.
This project is under license from Apache 2.0. For more details, see the LICENSE file.
Made with ❤️ by devenes