Book Sever
It is a RESTful API using Go, gorilla/mux, Basic Authentication, JWT Authentication.
Brief Description
I have built a fully-fledged REST API with Go that exposes GET, POST, DELETE and PUT endpoints which allows to perform the full range of CRUD operations. A handler function accepts http response and request in json format. Then, the request is decoded and written to response according to the called function. This handler function is wrapped by the authentication middleware to perform the security check.
API Endpoints
Authentication Method
- Basic Authentication
- JWT Authentication
Data Models
type Book struct {
ID string `json:"id"`
Isbn string `json:"isbn"`
Title string `json:"title"`
Author *Author `json:"author"`
}
type Author struct {
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
}
Installation
- go install github.com/Ahasannn/book-server-api@b687963
Set Environment variables for Basic Authentication.
export username=Ahasan
export password=ak4747
Testing the API endpoints
- Primary api endpoints can be tested with Postman
Server Run
go build -o bin/book-server-api .
./bin/book-server