Skip to content

Latest commit

 

History

History
45 lines (37 loc) · 1.25 KB

readme.md

File metadata and controls

45 lines (37 loc) · 1.25 KB

API Gateway

Purpose

The API Gateway serves as a centralized entry point that routes requests to multiple backend services. It includes middleware for logging, authentication, and rate limiting to enhance security and performance.

How to Run

Prerequisites

  1. Go installed on your local machine
  2. Docker and Docker Compose (optional for containerized deployment)

Local Installation

  1. Clone the repository:
git clone <repository-url>
cd api-gateway
  1. Initialize Go modules and run services:
go mod tidy
go run main.go
go run service1.go
go run service2.go

Docker Installation

Build and run with Docker Compose:

docker-compose up --build

Middleware and Functionality

Middleware

  1. Logging: Records incoming requests for debugging and analysis.
  2. Authentication: Verifies tokens to secure access to backend services.
  3. Rate Limiting: Controls the rate of requests to prevent abuse and ensure service availability.

Usage Example

Assume you have two backend services running locally:

  1. Service 1 on http://localhost:8001
  2. Service 2 on http://localhost:8002

The API Gateway routes requests as follows:

  1. /service1 proxies to http://localhost:8001
  2. /service2 proxies to http://localhost:8002