An basic API to demonstrate Go, gin and gorm
Table "User"
- id: integer / auto-increment
- name: varchar(255) / Not-Null
Routes
- POST : http://127.0.0.1:3001/api/v1/users
- GET : http://127.0.0.1:3001/api/v1/users
- GET : http://127.0.0.1:3001/api/users/1
- PUT : http://127.0.0.1:3001/api/users/1
- DELETE : http://127.0.0.1:3001/api/users/1
go get github.com/gin-gonic/gin
go get github.com/jinzhu/gorm
You need to create a new schema in your database and configure him in this project.
You can configure the connection strings from conn/mysql.go
curl -i -X POST -H "Content-Type: application/json" -d "{ \"name\": \"Zanoni\" }" http://localhost:3001/api/v1/users}
curl -i http://localhost:3001/api/v1/users/1
curl -i http://localhost:3001/api/v1/users
curl -i -X PUT -H "Content-Type: application/json" -d "{ \name\": \"Zanoni\" }" http://localhost:3001/api/v1/users/1}
curl -i -X DELETE http://localhost:3001/api/v1/users/1
Gustavo Zanoni - LinkedIn