https://github.com/devfurkankizmaz/fiber-clientside-cache
A simple API demonstrating client-side caching with Fiber
https://github.com/devfurkankizmaz/fiber-clientside-cache
client-side-caching crud-api fiber-framework golang restful-api
Last synced: 5 months ago
JSON representation
A simple API demonstrating client-side caching with Fiber
- Host: GitHub
- URL: https://github.com/devfurkankizmaz/fiber-clientside-cache
- Owner: devfurkankizmaz
- Created: 2023-06-25T16:24:07.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-25T16:45:34.000Z (almost 3 years ago)
- Last Synced: 2024-04-20T17:23:50.569Z (about 2 years ago)
- Topics: client-side-caching, crud-api, fiber-framework, golang, restful-api
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fiber Client-Side Caching CRUD API
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.
## Features
- `GET /api/tasks` endpoint retrieves a list of tasks. The response is cached on the client-side for a specific duration.
- `GET /api/tasks/:id` endpoint retrieves details of a specific task. The response is cached on the client-side for a specific duration.
- `POST /api/tasks` endpoint adds a new task to the collection.
- `PUT /api/tasks/:id` endpoint updates an existing task.
- `DELETE /api/tasks/:id` endpoint deletes a task from the collection.
## Installation
1. Clone the repository:
```bash
git clone
```
2. Navigate to the project directory:
```bash
cd fiber-clientside-cache
```
3. Install the dependencies:
```bash
go mod download
```
4. Start the server:
```bash
go run main.go
```
or
```bash
make docker-run
```
The server will be available at `http://localhost:3000`.
## Usage
You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:
- Get all tasks:
```bash
curl http://localhost:3000/api/tasks
```
- Get a specific task (replace `` with the actual task ID):
```bash
curl http://localhost:3000/api/tasks/
```
- Add a new task:
```bash
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 `` with the actual task ID):
```bash
curl -X PUT -H "Content-Type: application/json" -d '{"title":"Updated Task"}' http://localhost:3000/api/tasks/
```
- Delete a task (replace `` with the actual task ID):
```bash
curl -X DELETE http://localhost:3000/api/tasks/
```
## Configuration
You can modify the caching duration and other settings by editing the code in `main.go`.