This is a simple RESTful API for managing a todo list, built with Go and the Gin web framework.
- Go 1.18 or higher
- Docker (optional, for containerization)
- Clone the repository:
git clone https://github.com/Ashikurrahaman287/RESTful-API-.git
cd todo-api
- Initialize the Go module and download dependencies:
go mod tidy
- Install Gin framework:
go get github.com/gin-gonic/gin
- Run the application:
go run main.go
- The API will be available at
http://localhost:8080
.
- URL:
/todos
- Method:
POST
- Body:
{
"title": "New Todo"
}
- Success Response:
- Code:
201 CREATED
- Content:
{
"id": 1,
"title": "New Todo",
"completed": false
}
- URL:
/todos
- Method:
GET
- Success Response:
- Code:
200 OK
- Content:
[
{
"id": 1,
"title": "New Todo",
"completed": false
}
]
- URL:
/todos/:id
- Method:
GET
- Success Response:
- Code:
200 OK
- Content:
{
"id": 1,
"title": "New Todo",
"completed": false
}
- Error Response:
- Code:
404 NOT FOUND
- Content:
{
"error": "Todo not found"
}
- URL:
/todos/:id
- Method:
PUT
- Body:
{
"title": "Updated Todo",
"completed": true
}
- Success Response:
- Code:
200 OK
- Content:
{
"id": 1,
"title": "Updated Todo",
"completed": true
}
- Error Response:
- Code:
404 NOT FOUND
- Content:
{
"error": "Todo not found"
}
- URL:
/todos/:id
- Method:
DELETE
- Success Response:
- Code:
204 NO CONTENT
- Error Response:
- Code:
404 NOT FOUND
- Content:
{
"error": "Todo not found"
}
You can also run the application using Docker.
- Build the Docker image:
docker build -t todo-api .
- Run the Docker container:
docker run -p 8080:8080 todo-api
If you want to contribute to this project, feel free to submit issues or pull requests. [email protected]
This project is licensed under the MIT License.