A simple yet powerful RESTful API built with GoFiber and SQLite, supporting CRUD operations and dynamic database selection.
- CRUD operations (Create, Read, Update, Delete)
- Dynamic database selection based on API key / Resource Name
- Pagination and search functionality
All endpoints require an apiKey
header (optional).
GET /
: Retrieve all recordsPOST /
: Create a new recordPUT /:id
: Update a recordDELETE /:id
: Delete a record
GET /app/:resourceName
: Retrieve all records for a specific resourcePOST /app/:resourceName
: Create a new record for a specific resourcePUT /app/:resourceName/:id
: Update a record for a specific resourceDELETE /app/:resourceName/:id
: Delete a record for a specific resource
{
"key": "value",
"key2": "value2"
}
{
"message": "success",
"data": {
"id": "1234567890",
"key": "value",
"key2": "value2",
"created_at": 1234567890,
"updated_at": 1234567890
}
}
{
"message": "Something went wrong",
"data": null
}
{
"message": "success",
"data": {
"total": 100,
"page": 1,
"limit": 10,
"query": "search term",
"records": [
{
"id": "1234567890",
"key": "value",
"key2": "value2",
"created_at": 1234567890,
"updated_at": 1234567890
},
// ... more records
]
}
}
- Go (version 1.16 or higher)
- SQLite
-
Clone the repository:
git clone https://github.com/your-username/gofiber-api-sqlite.git cd gofiber-api-sqlite
-
Install dependencies:
go mod tidy
-
Run the application:
go run main.go
The API will be available at http://localhost:3000
.
.
├── Makefile
├── README.md
├── app
│ ├── handlers.go
│ ├── middleware.go
│ ├── routes.go
│ └── types.go
├── config
│ └── app.go
├── data
│ ├── 6ac99cc3d1a009c8eaeb44cf6cacf7f1.db
│ ├── c3fcd3d76192e4007dfb496cca67e13b.db
│ └── general.db
├── go.mod
├── go.sum
├── helpers
│ └── db.go
├── http.rest
└── main.go
curl -X POST http://localhost:3000/api \
-H "Content-Type: application/json" \
-d '{"key":"value", "key2":"value2"}'
curl http://localhost:3000/api
curl -X PUT http://localhost:3000/api/1234567890 \
-H "Content-Type: application/json" \
-d '{"key":"new_value"}'
curl -X DELETE http://localhost:3000/api/1234567890
This project is licensed under the MIT License.