This is a simple API built with Go and Fiber framework to demonstrate client-side caching. The API provides endpoints for managing a task collection.
GET /api/tasksendpoint retrieves a list of tasks. The response is cached on the client-side for a specific duration.GET /api/tasks/:idendpoint retrieves details of a specific task. The response is cached on the client-side for a specific duration.POST /api/tasksendpoint adds a new task to the collection.PUT /api/tasks/:idendpoint updates an existing task.DELETE /api/tasks/:idendpoint deletes a task from the collection.
- Clone the repository:
git clone <repository-url>- Navigate to the project directory:
cd fiber-clientside-cache- Install the dependencies:
go mod download- Start the server:
go run main.goor
make docker-runThe server will be available at http://localhost:3000.
You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:
- Get all tasks:
curl http://localhost:3000/api/tasks- Get a specific task (replace
<task-id>with the actual task ID):
curl http://localhost:3000/api/tasks/<task-id>- Add a new task:
curl -X POST -H "Content-Type: application/json" -d '{"title":"New Task","description":"Task description"}' http://localhost:3000/api/tasks- Update an existing task (replace
<task-id>with the actual task ID):
curl -X PUT -H "Content-Type: application/json" -d '{"title":"Updated Task"}' http://localhost:3000/api/tasks/<task-id>- Delete a task (replace
<task-id>with the actual task ID):
curl -X DELETE http://localhost:3000/api/tasks/<task-id>You can modify the caching duration and other settings by editing the code in main.go.