This is a learning project to create CRUD REST API without using any framework.
In this project implement Basic Auth and Bearer Auth.
- if we want to create any request to endpoint that implemented basic auth we should define username and password (Encode64) in the request header :
Authorization: Basic Base64(username:password)
- if we want to create any request to endpoint that implemented bearer auth we should define token the request header :
Authorization: Bearer <token>
Pre-requisite :
- Install MySQL server on machine
- Install go sql driver package :
go get -u github.com/go-sql-driver/mysql
- Install Gorilla Mux route package :
go get -u github.com/gorilla/mux
- Install JWT-Go :
go get github.com/dgrijalva/jwt-go
- Install bcrypt :
go get golang.org/x/crypto/bcrypt
Demo (using PostMan) :