A RESTful API example for simple book application in Golang
# Download this project
go get github.com/ericz99/go-server-api
Before running API server, you should set the database config with yours or set the your database config with my values on config.go
Also, please change .env.example -> .env and update the all fields.
# production env mode
mode = development
# database config
db_name = testdb
db_pass = passwrod
db_user = root
db_type = mysql
db_host = localhost
db_port = 3306
# server port
port = 8080
# for jwt secret key
secret_key = feTATm1?@d+1GKG
# Build and Run
cd go-server-api
go build
./go-server-api - [if you\'re using linux/macos]
go-server-api - [if you\'re using windows]
# API Endpoint (VERSION 1) : http://localhost:8080/api/v1
# API Endpoint (VERSION 2) : http://localhost:8080/api/v2
# API Auth Endpoint : http://localhost:8080/api/auth
POST
: Create new user
#Post Params
{
"name": "Hello World",
"email": "test@yahoo.com",
"password": "asdfasdf"
}
POST
: Login User
#Post Params
{
"email": "test@yahoo.com",
"password": "asdfasdf"
}
Please add x-auth-token
in your header in order to get authorized to any of these endpoint below!
POST
: Save a book
GET
: Get all book
GET
: Get a bookDELETE
: Delete a book
#Post Params
{
"title": "LOL: Book PT 2",
"isbn": "isbn-6s9",
"author": {
"name": "Bob"
}
}
- Support basic REST APIs.
- Support GORM/Database
- Support Authentication with user for securing the APIs.
- Make convenient wrappers for creating API handlers.
- Write the tests for all APIs.
- Organize the code with packages
- Make docs with GoDoc
- Building a deployment process