Skip to content

A simple example api gateway routes requests to backend services, with middleware for logging, authentication, and rate limiting to boost security and performance.

Notifications You must be signed in to change notification settings

zahidhasann88/api-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple example api gateway routes requests to backend services, with middleware for logging, authentication, and rate limiting to boost security and performance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published