# README
go-gin-xorm-starter
Golang API starter using Gin and xorm.
Requirements
- go (>= v1.14 recommended)
- docker & docker-compose
- nodemon for Live Reloading Development
Installation
Install nodemon
command
npm i -g nodemon
# or if you prefer yarn
yarn global add nodemon
Setup .env
File
Copy .env.example
to .env
.
cp .env.example .env
Install dependencies
go get
Develop with local Database
Start
Run Docker.
docker-compose up -d
Init Database.
sh ./fixtures/init_db.sh
Access Database using phpMyAdmin.
open http://localhost:9080/db_structure.php?db=go-gin-xorm-starter
Or, access Database using Adminer.
open http://localhost:10080/?server=mysql&username=root&pass=password
Let's get fruits!!
Start API server.
make start
get fruits using curl
.
curl http://localhost:3000/v1/fruits
Add new fruit
post fruit using curl
.
curl -X POST \
-H 'Authorization:Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImVtYWlsIjoidGVzdEBleGFtcGxlLmNvbSIsImlhdCI6MTUxNjIzOTAyMn0.hkDGuuaVbg2rBeEk3e97yUzl3Gp2UfD_hZO0dnjH6elS4WmxplQzXEXdOSvVaGFTxLpvwvTx11MT3PZzBUkoKR7WkGa76YdKiJGR-SZy7Zpdj6u1FdB9BGsIuvnfl0foX8En2JPV-EIA5Pm2fdy2hSGg1nzaPMekL8KeEJYjyi8' \
-d '{"name":"Lemon","price":144}' \
http://localhost:3000/v1/fruits
This sample JWT is generated here.
Shutdown
Stop Docker.
docker-compose down
Build Docker image
Build.
docker build -t myimage/starter .
Run.
Use -e
and --env-file
option to give environment variables.
docker run -p 8888:80 --env-file .env -e DATABASE_HOST=mydbhost myimage/starter
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author