roshanlc / go-crud-app

A basic REST API implementing crud functionalities with MySQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-crud-app

A CRUD REST API with mysql
Uses:

  • gorilla/mux
  • gorm

Implemented

  • [✔] GET /book returns list of books as JSON
  • [✔] GET /book/{id} returns details of a specific book as JSON
  • [✔] POST /book accepts a new book to be added
  • [✔] POST /book returns status 415 if content is not application/json

Data types

A book object should look like this:

{
    "id": 3,
    "title": "Karnali Blues",
    "author": "Buddhi Sagar",
    "publication": "XYZ"
}

Persistence

MYSQL database is used. Configure mysql database credentials by editing .../pkg/config/app.go

// Database credentials
var (
	username = "root"
	password = "password"
	db       = "crud_app"
)

Setup

go get "github.com/gorilla/mux"

go get 	"github.com/jinzhu/gorm"

go get "github.com/jinzhu/gorm/dialects/mysql"

go run cmd/main/main.go

About

A basic REST API implementing crud functionalities with MySQL.


Languages

Language:Go 100.0%