Percobaan membuat API dengan bahasa Go-lang.
- Gin - Web framework
- Gin Swaggo - Swagger Docs integration for Gin web framework
- Golang JWT v4 - JWT library for Go
- Go Yaml v2 - Go library for processing yaml files
Pada percobaan API ini hanya menyertakan 2 routing & 1 middleware.
- GET:
/cek_middleware
- POST:
/login
- Middleware:
AuthMiddleware
- Clone project nya
git clone https://github.com/yeyee2901/gin-web.git
- Buat direktori
/logs
&/deps
cd gin-web
mkdir logs
mkdir deps
- Set Environment Variable GOPATH & install dependency project secara lokal terhadap project
export GOPATH=$(pwd)/deps
go get
- Download and run
swaggo
go install github.com/swaggo/swag/cmd/swag@latest
# di direktori root project:
swag init --exclude deps
- Run Project
go run . # OR
go run main.go
- Setiap kali edit dokumentasi swagger, run
swag init --exclude deps
lagi untuk re-generate file docs yaml