Practice project to connect a REST API on Go made with Gin to AWS DynamoDB database.
To run this project you need to install Go and set your Go workspace first. Get Go binaries from the downloads page.
The project uses environment variables to get AWS keys to connect with AWS DynamoDB, you should follow these guides on how to setup the AWS CLI and configure your account.
The project assumes you have a Users table on your DynamoDB and it has an ID partition key. You must create it in order for the queries to work.
Clone the repo in your local machine by executing the following command in a terminal:
$ git clone https://github.com/DazSanchez/go-dynamodb-practice.git
$ cd go-dynamodb-practiceYou must install project's dependencies in order to be able to run it.
$ go get .Once you have installed the dependendies you can run the server with the following command:
$ go run .This will run the Gin server on port 8000.
Currently there's three endpoints for interacting with DynamoDB:
$ curl http://localhost:8000/users -H "Accept: application/json" $ curl http://localhost:8000/users/<user-id> -H "Accept: application/json" $ curl -X POST http://localhost:8000/users \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{ "name":"my_name", "firstSurname":"my_firstSurname", "email": "my_email" }'