Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agieaja/crudgolang
Sample API CRUD Golang And Gin
https://github.com/agieaja/crudgolang
api crud gin golang sample
Last synced: 3 months ago
JSON representation
Sample API CRUD Golang And Gin
- Host: GitHub
- URL: https://github.com/agieaja/crudgolang
- Owner: AgieAja
- Created: 2019-06-10T23:49:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-11T08:03:31.000Z (over 4 years ago)
- Last Synced: 2024-10-02T05:23:07.757Z (3 months ago)
- Topics: api, crud, gin, golang, sample
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sample API CRUD using Golang And Gin
Instalation
- 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
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}