HTTPBin is a server that helps you debug HTTP requests.
This application expects to receive the following environment variables:
- HTTPBIN_SERVICE_ID (default: "")
- HTTPBIN_SERVICE_PORT (default: "8888")
You can determine the server's behavior for a specific request-response cycle by sending predefined configuration headers, as follows:
Header: X-HttpBin-Status
Description: Determine the status code of the response.
Header: X-HttpBin-Sleep
Description: Determine a response delay in seconds.
Header: X-HttpBin-Content-Type
Description: Requests with payloads must declare their content type as the same as that accepted by the server, otherwise the server will return a 415 (Unsupported Media Type) status code.
Use the special path "/proxy" with the query param "to" to set the destination to which the request should be proxied. The response replicates the headers and body the destination server return.
curl -i "http://localhost:8888/proxy?to=https://google.com"
Use the special path "/health" the check service health. It return a simple 200 status code when the service is up and ready.
curl -i "http://localhost:8888/health"
go run cmd/httpbin/main.go
docker compose -f deployments/docker-compose.yml up --build
A JSON containing information about the request and the Container where the application is running.
curl -i "localhost:8888/some-path?products=notebook&products=tablet&customer=john"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 09 Jan 2024 13:41:57 GMT
Content-Length: 267
{
"serviceId": "container-01",
"remoteAddr": "127.0.0.1:57968",
"method": "GET",
"path": "/some-path",
"queryParams": {
"customer": [
"john"
],
"products": [
"notebook",
"tablet"
]
},
"headers": {
"Accept": [
"*/*"
],
"User-Agent": [
"curl/7.81.0"
]
}
}