A small app written in Golang to echo the HTTP client's IP and other request information.
Live: https://wiam.cc
Docker image: https://hub.docker.com/r/locnh/wiam/
GET /
{
"city": "Frankfurt am Main",
"country": "Germany",
"ip": "37.120.196.54"
}GET|POST|PUT|PATCH|DELETE /request?whatever
{
"cookies": {},
"headers": {
"Accept": "*/*",
"User-Agent": "curl/8.7.1"
},
"host": "localhost:8080",
"method": "GET",
"origin_ip": "::1",
"params": {},
"payload": "",
"query": {
"whatever": ""
},
"uri": "/request?whatever",
"user_agent": "curl/8.7.1"
}⏎GET /headers (returns request headers as JSON)
{
"User-Agent": ["curl/7.68.0"],
"X-Forwarded-For": ["37.120.196.54"],
...
}-
GET /ipReturn client IP as plain text.
Example:curl http://localhost:8080/ip
-
GET /uaReturn User-Agent (uses X-Real-User-Agent if present).
Example:curl -s http://localhost:8080/ua
-
GET /headersReturn request headers in JSON.
Example:curl -s http://localhost:8080/headers | jq -
GET /cookiesReturn cookies as JSON array.
Example:curl -s http://localhost:8080/cookies | jq -
GET /status/:codeRespond with the given HTTP status code.
Example:curl -i http://localhost:8080/status/404
-
GET /redirect/:nRedirect n times (0..10). n=0 returns 200 OK.
Example:curl -v http://localhost:8080/redirect/3
-
GET /auth/basic/:username/:passwordRequires HTTP Basic Auth; credentials are checked against the URL params.
Example (username: alice, password: secret):curl -i -u alice:secret "http://localhost:8080/auth/basic/alice/secret" -
GET /delay/:nDelay response by n seconds (0..10).
Example:curl -i http://localhost:8080/delay/3
- Request details are produced by the function
main.getAllRequestInfo. See src/main.go. - Client location lookup uses the country code map in src/countrycode.go and the function
main.getClientInfo. - Main entrypoint and routes: src/main.go
Default (release mode):
docker run -p 8080:8080 -d locnh/wiamDebug (GIN debug):
docker run -p 8080:8080 -e GIN_MODE=debug -d locnh/wiam- Fork the repository
- Make changes
- Create a pull request
- Enjoy a cup of tea