8000 GitHub - traefik/whoami: Tiny Go server that prints os information and HTTP request to output
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

traefik/whoami

Repository files navigation

whoami

Docker Pulls Build Status

Tiny Go webserver that prints OS information and HTTP request to output.

Usage

Paths

/[?wait=d]

Returns the whoami information (request and network information).

The optional wait query parameter can be provided to tell the server to wait before sending the response. The duration is expected in Go's time.Duration format (e.g. /?wait=100ms to wait 100 milliseconds).

The optional env query parameter can be set to true to add the environment variables to the response.

/api

Returns the whoami information (and some extra information) as JSON.

The optional env query parameter can be set to true to add the environment variables to the response.

/bench

Always return the same response (1).

/data?size=n[&unit=u]

Creates a response with a size n.

The unit of measure, if specified, accepts the following values: KB, MB, GB, TB (optional, default: bytes).

/echo

WebSocket echo.

/health

Heath check.

  • GET, HEAD, ...: returns a response with the status code defined by the POST
  • POST: changes the status code of the GET (HEAD, ...) response.

Flags

Flag Env var Description
cert Give me a certificate.
key Give me a key.
cacert Give me a CA chain, enforces mutual TLS
port WHOAMI_PORT_NUMBER Give me a port number. (default: 80)
name WHOAMI_NAME Give me a name.
verbose Enable verbose logging.

Examples

$ docker run -d -p 8080:80 --name iamfoo traefik/whoami

$ curl http://localhost:8080
Hostname: 9c9c93da54b5
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.2
RemoteAddr: 172.17.0.1:41040
GET / HTTP/1.1
Host: localhost:8080
User-Agent: curl/8.5.0
Accept: */*
# updates health check status
$ curl -X POST -d '500' http://localhost:8080/health

# calls the health check
$ curl -v http://localhost:8080/health
* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /health HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.5.0
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Date: Fri, 18 Apr 2025 13:36:02 GMT
< Content-Length: 0
$ openssl req -newkey rsa:4096 \
    -x509 \
    -sha256 \
    -days 3650 \
    -nodes \
    -out ./certs/example.crt \
    -keyout ./certs/example.key

$ docker run -d -p 8080:80 -v ./certs:/certs --name iamfoo traefik/whoami --cert /certs/example.crt --key /certs/example.key

$ curl https://localhost:8080 -k --cert certs/example.crt  --key certs/example.key
Hostname: 25bc0df47b95
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.2
RemoteAddr: 172.17.0.1:50278
Certificate[0] Subject: CN=traefik.io,O=TraefikLabs,L=Lyon,ST=France,C=FR
GET / HTTP/1.1
Host: localhost:8080
User-Agent: curl/8.5.0
Accept: */*
$ docker run -d -p 8080:80 --name iamfoo traefik/whoami

$ grpcurl -plaintext -proto grpc.proto localhost:8080 whoami.Whoami/Whoami
{
  "hostname": "5a45e21984b4",
  "iface": [
    "127.0.0.1",
    "::1",
    "172.17.0.2"
  ]
}

$ grpcurl -plaintext -proto grpc.proto localhost:8080 whoami.Whoami/Bench
{
  "data": 1
}
version: '3.9'

services:
  whoami:
    image: traefik/whoami
    command:
       # It tells whoami to start listening on 2001 instead of 80
       - --port=2001
       - --name=iamfoo

About

Tiny Go server that prints os information and HTTP request to output

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 
0