Categorygithub.com/koshyari/go-RESTAPI
modulepackage
0.0.0-20210324164746-db22c48e69d1
Repository: https://github.com/koshyari/go-restapi.git
Documentation: pkg.go.dev

# README

go-RESTAPI

Simple RESTful API to create, read, update and delete users.

Quick Start

Object-relational-mapping is the idea of being able to write SQL queries using the object-oriented paradigm of your preferred programming language. Hence we are using the ORM for Golang - GORM

# Install mux router
go get -u github.com/gorilla/mux

# Install gorm 
go get -u gorm.io/gorm

# Install MySQL driver for gorm
go get -u gorm.io/driver/mysql
go build
./go-RESTAPI

Database

In the db.go file, add your MySQL details

const DSN = "<username>:<password>@tcp(127.0.0.1:3306)/<schema_name>?charset=utf8mb4&parseTime=True&loc=Local"

Endpoints

Get All Users

GET api/users

Get Single User

GET api/users/{id}

Delete User

DELETE api/users/{id}

Create User

POST api/users

# Request sample
# {
#   "firstname":"Anshul",
#   "lastname":"Koshyari",
#   "email":"[email protected]" 
# }

Update User

PUT api/users/{id}

# Request sample
# {
#   "firstname":"Fazle",
#   "lastname":"Ejazi",
#   "email":"[email protected]"
# }

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

Add your MySQL DSN here.

# Variables

No description provided by the author

# Structs

Defined ORM model.