This README provides instructions on how to test the API Gateway. The gateway is designed to route requests to the appropriate services based on the request path. Before testing, ensure the gateway and all backend services are running.
- API Gateway running on port 8080
- Backend services (e.g., UserService and ProductService) configured and running as per the gateway configuration
Make sure the API Gateway is running by executing the Go application:
go run gw/main.go
This starts the API Gateway on http://localhost:8080.
If the UserService is configured to be accessible through /UserService/*, use the following curl command to test routing to the UserService:
curl http://localhost:8080/UserService/users
You should receive a JSON response from the UserService, indicating that the API Gateway has successfully routed the request.
If the ProductService is configured to be accessible through /ProductService/*, use the following curl command to test routing to the ProductService:
curl http://localhost:8080/ProductService/products
You should receive a JSON response from the ProductService, confirming that the API Gateway has successfully routed the request.
Docker Compose allows you to manage multi-container Docker applications. To use Docker Compose to start and stop your project, follow these steps:
-
Ensure Docker Compose is installed: Docker Compose should be installed on your system. For installation instructions, visit the official Docker documentation.
-
Create a
docker-compose.yml
file: This file should define your services, networks, and volumes. Place this file at the root of your project directory. -
Start the services: Navigate to the root of your project directory in a terminal and run the following command to start all services defined in your
docker-compose.yml
file:
docker-compose up -d
This command starts the services in detached mode, running them in the background.
To stop and remove all the running services defined in the docker-compose.yml
file, run:
docker-compose down
This command stops all running containers and removes containers, networks, volumes, and images created by docker-compose up
.