This service acts as the entrypoint to all client traffic and handles request forwarding to individual microservices such as auth-service
and dashboard-service
. It also manages authentication, routing, and headers.
git clone https://github.com/dashboard-platform/api-gateway.git
cd api-gateway
- Create a
.env
file. - Run:
go run cmd/main.go
.env
file example: (for details, see below)
PORT=:8080
AUTH_SERVICE_URL=http://auth-service:8080
DASHBOARD_SERVICE_URL=http://dashboard-service:8080
JWT_SECRET=supersecretkey
COOKIE_SECURE=false
docker build -t api-gateway .
docker run -p 8080:8080 --env-file .env api-gateway
This will start the api-gateway
on port 8080
.
Access healthcheck:
curl http://localhost:8080/healthcheck
To run the whole test suite, use:
cd api-gateway
go tests -v ./...
Variable | Description |
---|---|
PORT |
Port on which the service runs (:8080 ) |
AUTH_SERVICE |
Address where auth-service is running |
DASHBOARD_SERVICE |
Address where dashboard-service is running |
JWT_SECRET |
Secret used for signing JWTs (secret ) |
COOKIE_SECURE |
Use secured cookies or not |
- Centralized routing for all internal APIs
- JWT validation middleware (from cookie or bearer token)
- Forwarding to internal microservices:
/auth/*
→auth-service
/dashboard/*
→dashboard-service
- Cookie handling and header normalization
- Built-in support for CORS and secure HTTP headers
Method | Path | Auth Required | Description |
---|---|---|---|
GET | /healthcheck |
❌ | Basic service |