Sign inSign up

houstonj1/echoserver

By houstonj1

Updated 14 days ago

A simple echoserver written in Go

Image
Developer tools
0

8.4K

houstonj1/echoserver repository overview

echoserver

A tiny, single-binary HTTP echo server written in Go. Send it a request on any path and it replies with the request's metadata, headers, host, and body — handy for inspecting what a client, proxy, ingress, or load balancer actually sends.

Features

  • Echoes everything — method, path, protocol, query parameters, sorted headers, resolved host, and body, all in plain text.
  • Smart body handling — valid JSON is pretty-printed, form-encoded bodies are expanded as key = value, and anything else is echoed verbatim.
  • Safe by default — request bodies are capped at 1 MiB (returns 413), read/header timeouts bound slow clients, and shutdown drains in-flight requests.
  • Minimal image — built on distroless/static:nonroot, multi-arch (linux/amd64, linux/arm64), and only a few MB in size.

Supported tags

  • latest — the most recent release.
  • vX (e.g. v1) — the latest release of a major version.
  • vX.Y.Z (e.g. v1.7.3) — a specific immutable release. Pin this in production.

Pull a tag with docker pull houstonj1/echoserver:<tag>.

Quick start

docker run --rm -p 3000:3000 houstonj1/echoserver

Then send it a request:

curl -X POST 'http://localhost:3000/api/test?debug=true' \
  -H 'Content-Type: application/json' \
  -d '{"hello":"world","n":42}'

Response:

Request Information:
    Client Address: 172.17.0.1:54895
    Method: POST
    Path: /api/test
    Protocol: HTTP/1.1
    Query Parameters: debug=true

Request Headers:
    Accept: */*
    Content-Length: 24
    Content-Type: application/json
    User-Agent: curl/8.7.1
    Host: localhost

Request Body:
{
    "hello": "world",
    "n": 42
}

Configuration

VariableDefaultDescription
PORT3000TCP port to listen on. Must be an integer in the range 165535.
docker run --rm -e PORT=8080 -p 8080:8080 houstonj1/echoserver

Kubernetes

kubectl create namespace echoserver

kubectl create deployment echoserver \
  --image houstonj1/echoserver \
  --port 3000 \
  --replicas 2 \
  -n echoserver

kubectl expose deployment echoserver -n echoserver
kubectl port-forward svc/echoserver 3000:3000 -n echoserver

For a production-ready setup, apply a manifest with resource limits, readiness and liveness probes, and a hardened security context:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: echoserver
  labels:
    app: echoserver
spec:
  replicas: 2
  selector:
    matchLabels:
      app: echoserver
  template:
    metadata:
      labels:
        app: echoserver
    spec:
      containers:
        - name: echoserver
          image: houstonj1/echoserver
          ports:
            - containerPort: 3000
          resources:
            requests:
              cpu: 10m
              memory: 16Mi
            limits:
              memory: 32Mi
          readinessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 1
          livenessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 5
          securityContext:
            runAsNonRoot: true
            readOnlyRootFilesystem: true
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
---
apiVersion: v1
kind: Service
metadata:
  name: echoserver
  labels:
    app: echoserver
spec:
  selector:
    app: echoserver
  ports:
    - name: http
      port: 80
      targetPort: 3000

Tag summary

Content type

Image

Digest

sha256:f6e29f86c

Size

3.3 MB

Last updated

14 days ago

docker pull houstonj1/echoserver