A simple REST API built with Golang, Echo, Gorm, and following Clean Architecture principles. It includes JWT authentication and connects to a MySQL database.
- Golang
- Echo (Web Framework)
- Gorm (ORM for Golang)
- MySQL
- Clean Architecture
- JWT
Ensure the following environment variables are set before running the application:
DB_HOST
: MySQL database hostDB_PORT
: MySQL database portDB_USERNAME
: MySQL database usernameDB_PASSWORD
: MySQL database passwordDB_NAME
: MySQL database nameJWT_SECRET
: Secret key for JWT authentication
- Create .env file, with environment variables
- Start Database
- Run the Project using
go run .
Run the Docker container with the provided example command:
docker run --name go-simple-clean-rest-api -p 8080:8080 -d \
-e DB_HOST=localhost \
-e DB_PORT=3306 \
-e DB_NAME=go-simple-clean-rest-api \
-e DB_USERNAME=root \
-e DB_PASSWORD=12345678 \
-e JWT_SECRET=kayokoonikata \
aszaychik/go-simple-clean-rest-api:latest
- Method: GET
- URL:
http://localhost:8080/users
- Auth:
Bearer Token required
- Method: GET
- URL:
http://localhost:8080/users/:id
- Auth:
Bearer Token required
- Method: POST
- URL:
http://localhost:8080/users/
- Body:
{ "name": "AsZ", "email": "asz@gmail.com", "password": "12345678" }
- Method: PUT
- URL:
http://localhost:8080/users/:id
- Auth:
Bearer Token required
- Body:
{ "name": "AsZ", "email": "asz@gmail.com", "password": "12345678" }
- Method: DELETE
- URL:
http://localhost:8080/users/:id
- Auth:
Bearer Token required
- Method: POST
- URL:
http://localhost:8080/users/login
- Body:
{ "email": "asz@gmail.com", "password": "12345678" }