Sign inSign up

paulovigne/goapp-crud

By paulovigne

Updated over 3 years ago

Image
0

5.0K

paulovigne/goapp-crud repository overview

Git: https://github.com/paulovigne/goapp

Simple Go CRUD App with PostgreSQL Database

Types

FieldTypeReference
IDint64json:"id"
Namestringjson:"name"
Locationstringjson:"location"
Ageint64json:"age"

Methods

GET "/api/user/{id}"
GET "/api/user"
POST "/api/newuser"
PUT "/api/user/{id}"
DELETE "/api/deleteuser/{id}"

Create Registry

curl -d '{"name":"paulo", "location":"rio", "age":38}'  -H "Content-Type: application/json" -X POST http://localhost:8080/api/newuser

Update Registry

curl -d '{"name":"pedro", "location":"rio", "age":38}'  -H "Content-Type: application/json" -X PUT http://localhost:8080/api/user/{id}

List Users

curl -H "Content-Type: application/json" -X GET http://localhost:8080/api/user

User Details

curl -H "Content-Type: application/json" -X GET http://localhost:8080/api/user/{id}

Delete User

curl -H "Content-Type: application/json" -X DELETE http://localhost:8080/api/deleteuser/{id}

Database Connection

URL Variable Example
POSTGRES_URL=postgres://user:pass@<db-host-ip-addr>:5432/databasename?sslmode=disable

Docker Reference

Clone and Build
git clone https://github.com/paulovigne/goapp.git
cd goapp
docker build -t goapp-crud .
Example of PostgreSQL Database Backend
mkdir -p /postgresql
chown -R 1001:1001 /postgresql

docker run \
   --name postgresql \
   -e POSTGRESQL_USERNAME=goappuser \
   -e POSTGRESQL_PASSWORD=goapppass \
   -e POSTGRESQL_DATABASE=goappdb \
   -p 5432:5432 \
   -v /postgresql:/bitnami/postgresql/data \
   quay.io/bitnami/postgresql:13
Create Tables
docker run \
   --name=migrate \
   -e POSTGRES_URL=postgres://goappuser:goapppass@<db-host-ip-addr>:5432/goappdb?sslmode=disable \
   goapp-crud \
   /app/migrate
Start Goapp
docker run -d \
   --name=goapp \
   -p 8080:8080 \
   -e POSTGRES_URL=postgres://goappuser:goapppass@<db-host-ip-addr>:5432/goappdb?sslmode=disable \
   goapp-crud

Tag summary

Content type

Image

Digest

sha256:284859493

Size

61.7 MB

Last updated

over 3 years ago

docker pull paulovigne/goapp-crud