echo-headers

A very simple webserver in Golang that prints all headers reaching it.

The code is mostly copy+paste from these repositories:

Run

Using Docker

The simplest way to run would be to use docker.

Docker Build

To build docker container image, from the root of this project, simply run:

docker build -t local/echo-headers .

Docker Run

Once the docker container image is build, simply run:

docker run --name echo-headers -p 8080:8080 local/echo-headers:latest

Directly from command line

To run this webserver, pre-requisite is to have go 1.23+ installed. Once that’s met, from root of the project, simply run:

go run main.go

To build this webserver, run

go build .

This will generate echo-headers binary in current directory. Then to run the webserver, run:

./echo-headers

To check help, run:

$ ./echo-headers --help
Usage of ./echo-headers:
  -host string
        interface to listen on (default "0.0.0.0")
  -port string
        port to listen on (default "8080")

Check Run

If the run is successful, the output should look something like this:

2024/10/10 12:02:17 [INFO] server is listening on 0.0.0.0:8080

Test

To test, run this from command line:

curl -H "Custom-Header: SomeValue" http://localhost:8080/

the output should look like this:

{"Accept":"*/*","Custom-Header":"SomeValue","User-Agent":"curl/8.7.1"}

Helm Chart

This GitHub Pages site hosts the Helm chart repository for echo-headers.

It is published from the gh-pages branch of this repo and should contain:

Add Helm Repository

helm repo add echo-headers https://abhinav1107.github.io/echo-headers/
helm repo update

Verify the chart is visible:

helm search repo echo-headers
# or
helm search repo echo-headers/echo-headers

Install chart

Create a namespace (optional, recommended):

kubectl create namespace echo-headers --dry-run=client -o yaml | kubectl apply -f -

install:

helm upgrade --install echo-headers echo-headers/echo-headers --namespace echo-headers

Uninstall:

helm uninstall echo-headers --namespace echo-headers

Using custom values

Export the default values:

helm show values echo-headers/echo-headers > values.yaml

Edit values.yaml, then install/upgrade with it:

helm upgrade --install echo-headers echo-headers/echo-headers --namespace echo-headers -f values.yaml