Simple master detail web crud with Golang and pREST
-
Postgresql --> Database
-
pREST --> API REST
-
gatekeeper --> Autentication server
-
App frontend --> serv application pages (html)
-
Caddy --> Proxy
go get github.com/prest/prest
go get github.com/mholt/caddy/caddy
- plataform dependent
createdb gocrud
attention: To run pREST you need a precreated database
export PREST_HTTP_PORT=3000
export PREST_PG_HOST=127.0.0.1
export PREST_PG_USER=postgres
#export PREST_PG_PASS=
export PREST_PG_DATABASE=gocrud
export PREST_PG_PORT=5432
export PREST_JWT_KEY="your jwt key here"
export PREST_MIGRATIONS=./postgresql
export PREST_QUERIES_LOCATION=./queries
prest migrate up
prest
./gatekeeper
curl --user gocrud@example.com:1234 localhost:4000
Then get the jwt token and put the value on $JWT_TOKEN environment variable, to test pREST.
curl -i -H 'authorization: Bearer $JWT_TOKEN localhost:3000/databases
You must see your databases now.
./frontendapp
caddy -conf ./caddy/Caddyfile