HTTP Server Example
This GoFr example demonstrates a simple HTTP server which supports Redis and MySQL as datasources.
To run the example, follow the steps below:
1. Run with Docker Compose (recommended)
From the project root (/gofr):
docker compose -f examples/http-server/docker/docker-compose.yml up -d
-
Explanation:
-f examples/http-server/docker/docker-compose.yml → path to the docker-compose file
up -d → builds (if needed) and runs services in detached mode
2. Build & Run Manually (without docker-compose)
Build the Docker image
From the project root (/gofr):
docker build -f examples/http-server/Dockerfile -t http-server:latest .
-
Explanation:
-f examples/http-server/Dockerfile → path to the Dockerfile
-t http-server:latest → tag for the Docker image
. → build context (project root; needed for go.mod and go.sum)
Run the Docker container
docker run -p 9000:9000 --name http-server http-server:latest
To test the example, follow these steps:
- Open your browser and navigate to
http://localhost:9000/hello.
- To view the GoFr trace, open
https://tracer.gofr.dev and paste the traceid.
- To access the Grafana Dashboard, open
http://localhost:3000. The dashboard UI will be displayed. Use the default admin credentials to log in:
- Username:
admin
- Password:
password