This is a simple REST server built using the Fiber web framework in Golang. It provides a basic To-Do List API with endpoints to create, retrieve, update, and delete tasks.
- Clone the repository:
git clone https://github.com/Lingesh15/Golang-REST-Server.git
- Navigate to the project directory:
cd Golang-REST-Server
- Install dependencies:
go mod tidy
- Run the server:
go run main.go
By default, the server runs on http://localhost:3000
.
Endpoint: GET /api/todos
cURL Command:
curl -X GET http://localhost:3000/api/todos
Response:
[
{
"id": 1,
"body": "First todo",
"completed": false
}
]
Endpoint: POST /api/todos
cURL Command:
curl -X POST http://localhost:3000/api/todos -H "Content-Type: application/json" -d "{\"body\": \"This is my todo\"}"
Response:
{
"id": 1,
"body": "This is my todo",
"completed": false
}
Endpoint: PUT /api/todos/:id
cURL Command:
curl -X PUT http://localhost:3000/api/todos/1 -H "Content-Type: application/json"
Response:
{
"id": 1,
"body": "This is my todo",
"completed": true
}
Endpoint: DELETE /api/todos/delete/:id
cURL Command:
curl -X DELETE http://localhost:3000/api/todos/delete/1 -H "Content-Type: application/json"
Response:
{
"message": "Todo deleted successfully"
}
.
├── main.go # Entry point for the server
├── go.mod # Module file for dependencies
├── go.sum # Checksum file for dependencies
└── README.md # Documentation