This project is a simple RESTful CRUD (Create, Read, Update, Delete) API for managing todos. It provides basic operations to interact with a todo list, allowing users to create, read, update, and delete todo items.
I built this project to get started with Go.
-
Get all todos
- Endpoint:
GET /todo
- Description: Retrieve a list of all todos.
- Endpoint:
-
Create a new todo
- Endpoint:
POST /todo
- Payload:
- Name (string): The name of the todo.
- Description (string): A description of the todo.
- Completed (boolean): Indicates whether the todo is completed.
- ID (number): Unique identifier for the todo.
- Description: Create a new todo with the provided information.
- Endpoint:
-
Update a todo by ID
- Endpoint:
PUT /todo/{id}
- Payload:
- Name (string): The updated name of the todo.
- Description (string): The updated description of the todo.
- Completed (boolean): The updated completion status of the todo.
- Description: Update an existing todo identified by its ID with the provided information.
- Endpoint:
-
Delete a todo by ID
- Endpoint:
DELETE /todo/{id}
- Description: Delete a todo item based on its unique ID.
- Endpoint:
Visit the live deployment of this API: Todo CRUD API
To run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/mecies/go-todo-crud.git
-
Install dependencies:
cd go-todo-crud go install
-
Create a .env file and populate the following vars (requires a Postgres DB)
DB_USER= DB_PASS= DB_HOST= DB_NAME= DB_PORT= PORT=
-
Run the project:
go run main.go
The API will be accessible at
http://localhost:{PORT}
.
This project is licensed under the do-whatever-you-want-license.