This is a simple REST API written in Golang using the Fiber framework, GORM and PostgreSQL.
- Golang 1.21.1
- Fiber v2.49.2
- Install Golang
- Install PostgreSQL
- Install Fiber
- Install GORM
- Install GORM PostgreSQL Driver
- Clone this repository
- Create a database in PostgreSQL
- Copy
.env.example
to.env
and change some values - Run
go get
to install all dependencies - Run
go run main.go
to start the server - Open your browser and go to
http://localhost:3000/api/note
to see the list of notes
Method | Endpoint | Description |
---|---|---|
GET | /api/note | Get all notes |
GET | /api/note/:id | Get a single note |
POST | /api/note | Create a new note |
PUT | /api/note/:id | Update a note |
DELETE | /api/note/:id | Delete a note |
Example Create a new note
```json
{
"title": "Test",
"subtitle": "Testsss",
"text": "Test Juga"
}
```
- Open your browser and go to
http://localhost:3000/docs
to see the swagger documentation