A simple HTTP service written in Go that receives requests and prints all request headers.
- Listens on port
:8080 - Logs all request headers to the terminal
- Returns request method, path, and all headers in the HTTP response as plain text
- Uses a
panicrecover middleware to catch panics and respond with HTTP 500
go run main.goThen visit:
curl -H "X-Test: hello" http://localhost:8080/Or open http://localhost:8080/ in your browser to see the headers.
make buildThis produces a binary named header-checker.
Build the image:
make docker-buildRun the container:
make docker-runThen visit http://localhost:8080/.
The Makefile includes a target using docker buildx for multi-architecture builds.
First log in to Docker Hub:
docker loginBuild and push (replace with your own Docker Hub username):
make docker-buildx-push DOCKER_USER=your-dockerhub-usernameThis builds for linux/amd64 and linux/arm64 and pushes the image to:
your-dockerhub-username/header-checker:latest