- Create some database and Import table in the folder database on MYSQL
-
Open your terminal and run command :
- go get github.com/gin-contrib/logger
- go get github.com/gin-gonic/gin
- go get github.com/rs/zerolog
- go get github.com/rs/zerolog/log
- go get github.com/jinzhu/gorm
- go get github.com/go-sql-driver/mysql
-
Change the contents of the connectdb.go file in the config folder as follow :
- dbHost := "your host name / IP database"
- dbPort := "your port hostname / IP database"
- dbUser := "your user database"
- dbPass := "your password database"
- dbName := "your database name"
- Open your terminal on the root project and run command go run main.go
Module | Method | URL | Description | Request Body |
---|---|---|---|---|
Add | POST | {baseURL}/phonebook/add | Add some data in table phone_books | {"name":"Tiar","phone":"12346"} |
Edit | POST | {baseURL}/phonebook/edit | edit some data in table phone_books | {"id":1,"name":"Tiar","phone":"12346"} |
List | GET | {baseURL}/phonebook/list | get all data in table phone_books | - |
Get Data by ID | GET | {baseURL}/phonebook/data/id | get data by id in table phone_books | - |
Delete | POST | {baseURL}/phonebook/delete | delete some data in table phone_books | {"id":1} |