π API Gateway with Gin
Welcome to the awesome API Gateway project using the Gin framework in Go! π
β¨ Key Features
- π§ Smart routing to the right microservices
- π JWT Authentication for maximum security
- π¦ Rate Limiting to keep the server stable
- π Advanced logging for monitoring
- βοΈ Flexible configuration management
π Prerequisites
Before you start, make sure you have:
- πΉ Go - Latest Version
- π³ Docker (optional, for containerization)
π Installation
Follow these steps to get started:
- π₯ Clone this repository:
git clone https://github.com/yourusername/api-gateway.git
cd api-gateway
- π¦ Install dependencies:
go mod tidy
- π Create a
config.yaml
file in the project root or config/
directory with your configuration settings.
βοΈ Configuration
Your config.yaml
file should contain:
server_address: ":8080"
jwt_secret: "SERCRET_KEY_HERE"
rate_limit: 100
services:
users: "http://users-service:8081"
products: "http://products-service:8082"
orders: "http://orders-service:8083"
Adjust these values to match your setup! π
π Usage
To run the API Gateway:
go run main.go
The server will start at the address you specified in the config file. Happy experimenting! π
π£ API Endpoints
The API Gateway will forward requests to the appropriate microservice based on the URL path:
π€ /api/users/*: Forwarded to Users service
π /api/products/*: Forwarded to Products service
π¦ /api/orders/*: Forwarded to Orders service
Remember, all requests require a valid JWT token in the Authorization header! π
π License
This project is licensed under the MIT License. Feel free to use it, but don't forget to give stars! π