Simple of CRUD REST API backed by DynamoDB wrote in Golang based on AWS SDK V2
- GOLANG 1.16.3
- GOFIBER v2
- AWS SDK GO V2
- In your machine install AWS-CLI and CONFIGURE to save configuration of the your database
- You also need DOCKER
If you already have golang installed you can install packages by running the command:
go get -u ./...
docker run -p 8000:8000 amazon/dynamodb-local
go run scripts/createTable.go
Verify that the table is created:
go run scripts/listTable.go
You should see:
0 Books
To start the project run the command:
go run api/main.go
You can see in your terminal this log:
service running on port :3000
GET - http://localhost:3000/
This route creates an item in your database
POST - http://localhost:3000/api/books
{
"Title": "WhyJavaSucks"
"Author": "me"
}
curl -d "Title=WhyJavaSucks&Author=Me" -X POST -H "Accept: application/json" http://localhost:3000/api/books
This route returns all data in your database
GET - http://localhost:3000/api/books
This route updates an item in your database
PUT - http://localhost:3000/api/books/
{
"Title": "WhyJavaSucks"
"Author": "me"
"Rate": "0.8"
}
or
curl -d "Title=WhyJavaSucks&Author=Me&Rating=0.8" -X PUT -H "Accept: application/json" http://localhost:3000/api/books
This route removes an item in your database
DELETE - http://localhost:3000/api/books/
{
"Title": "WhyJavaSucks"
"Author": "me"
}