Skip to content

A full working server model of a bookstore using gorilla/mux for routing and gorm for interacting with the MySQL database.

Notifications You must be signed in to change notification settings

hemanth-ks97/bookstore-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This project implements a backend server written in Go for a bookstore. It persists data in a mysql database (MariaDB) hosted locally on the machine. The server supports the following CRUD APIs:-

  1. Create book -> POST on /book
  2. Update book by ID -> PUT on /book/{Id}
  3. Read all books -> READ on /book
  4. Read book by ID -> READ on /book/{Id}
  5. Delete book by ID -> DELETE on /book/{Id}

These APIs have been tested and verified using postman

Steps to run the project

  1. Install MariaDB on your machine
  2. Create a Database 'bookstore'
  3. Run the following command in MariaDB to grant access to the database for a new user (which will be used by the Go project to access the database).

grant all on bookstore.* to '{yourUserName}'@localhost identified by '{yourPasswd}'

  1. Open the file /pkg/config/app.go
  2. Edit line 11 with {yourUserName} and {yourPasswd} set in step 3 as follows:-

d, err := gorm.Open("mysql", "{yourUserName}:{yourPasswd}@/bookstore?charset=utf8mb4&parseTime=True&loc=Local")

  1. Run "go build" in the /cmd/main directory in your terminal
  2. Run "go run main.go" command in the terminal
  3. Use postman to test the APIs defined above

About

A full working server model of a bookstore using gorilla/mux for routing and gorm for interacting with the MySQL database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages