nzoschke / gofaas

A boilerplate Go and AWS Lambda app. Demonstrates an expert configuration of 10+ AWS services to support running Go functions-as-a-service (FaaS).
Apache License 2.0
801 stars 43 forks source link

DB - DynamoDB and Users API #18

Closed nzoschke closed 6 years ago

nzoschke commented 6 years ago
$ curl -X POST http://localhost:3000/users -d '{"username":"noah"}'
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "username": "noah"
}

$ curl http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "username": "noah"
}

$ curl http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb?token=true
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "token": "abf1ef90-f0f5-4d1a-8e9f-93515527eca5",
  "username": "noah"
}

$ curl -d '{"username": "nzoschke"}' -X PUT http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "username": "nzoschke"
}

$ curl http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb?token=true
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "token": "abf1ef90-f0f5-4d1a-8e9f-93515527eca5",
  "username": "nzoschke"
}

$ curl -X DELETE http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb
{
  "id": "4c47648f-e419-456b-97b8-22f82a9df6cb",
  "username": "nzoschke"
}

$ curl -X DELETE http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb
{"error": "not found"}

$ curl http://localhost:3000/users/4c47648f-e419-456b-97b8-22f82a9df6cb
{"error": "not found"}
$ aws dynamodb get-item --table-name gofaas-UsersTable-1CYAQH3HHHRGW --key '{"id": {"S": "4c47648f-e419-456b-97b8-22f82a9df6cb"}}'
{
    "Item": {
        "id": {
            "S": "4c47648f-e419-456b-97b8-22f82a9df6cb"
        },
        "username": {
            "S": "noah"
        },
        "token": {
            "B": "AQICAHj71FlbEg9QlwX27Ddgqme/q9vzr9RZ7R9G3rWcn+YSawEFpsCXMppuxW7sgOf0we8sAAAAgzCBgAYJKoZIhvcNAQcGoHMwcQIBADBsBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDHcPgVb2dWbFlbHkkwIBEIA/N9GKqdR8OjEf8OFDzQZIb8+lMHkahVl5qZvozMLykrCb9Q3HMZIF4qPXMOdlMPwIIueJ8CgTwzDe7oczelkv"
        }
    }
}