Skip to content

Simple example of CRUD REST API backed by DynamoDB wrote in Golang

License

Notifications You must be signed in to change notification settings

jrichard8/go-crud-dynamodb-gofiber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-crud-dynamodb-gofiber

Simple of CRUD REST API backed by DynamoDB wrote in Golang based on AWS SDK V2

TECH STACK

Getting Started

Pre-requirements

  • In your machine install AWS-CLI and CONFIGURE to save configuration of the your database
  • You also need DOCKER

Install

If you already have golang installed you can install packages by running the command:

go get -u ./...

Start DynamoDB local

docker run -p 8000:8000 amazon/dynamodb-local

Create Table

go run scripts/createTable.go

Verify that the table is created:

go run scripts/listTable.go

You should see:

0 Books

Init server

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

Usage

Base Route

    GET - http://localhost:3000/

Post

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

Get_All

This route returns all data in your database

    GET - http://localhost:3000/api/books

Put

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

Delete

This route removes an item in your database

    DELETE - http://localhost:3000/api/books/
    {   
        "Title": "WhyJavaSucks"
        "Author": "me"
    }

About

Simple example of CRUD REST API backed by DynamoDB wrote in Golang

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages