/go-gin-boilerplate

REST api JWT auth template (Golang + Gin)

Primary LanguageGo

Golang + Gin REST API template

Go JWT Postgres Redis Swagger Docker Grafana Prometheus Firebase

Small REST API template written in Golang using Gin, PostgreSQL, JWT and Redis. Project: user profile CRUD with authorization, authentication and token validation, Swagger generator and metrics gainer


Endpoints:

  1. POST:/api/v1/users - registrates new user
  2. POST:/api/v1/auth - authorizes user, generates JWT token and writing it in cache
  3. POST:/api/v1/auth/changePassword - changes password with deleting valid token in Redis valid tokens storage (requires token in Bearer header)
  4. GET:/api/v1/users/:username - get user profile by username (requires token in Bearer header)
  5. GET:/api/v1/users/me - returns current user profile (requires token in Bearer header)
  6. PATCH:/api/v1/users/me - updates current user profile (requires token in Bearer header)

Launch guide:

  • To launch webapp run:
docker compose up --build