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: Specifies the status code of the response.
Header: X-HttpBin-Sleep
Description: Specifies a response delay in seconds.
Header: X-HttpBin-Content-Type
Description: Requests with payloads must declare a content type that matches the one 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 returns.
curl -i "http://localhost:8888/proxy?to=https://google.com"
Use the special path "/health" to check service health. It returns 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.
Conteúdo do arquivo payload.json
:
{
"name": "John Doe",
"email": "[email protected]"
}
curl -i -H "Content-Type: application/json" -X POST "localhost:8888/some-path?fruits=apple&fruits=orange&drink=juice" -d @payload.json
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 09 Jan 2024 13:41:57 GMT
Content-Length: 340
{
"serviceId": "container-01",
"remoteAddr": "127.0.0.1:57968",
"method": "POST",
"path": "/some-path",
"queryParams": {
"drink": [
"juice"
],
"fruits": [
"apple",
"orange"
]
},
"headers": {
"Accept": [
"*/*"
],
"Content-Length": [
"60"
],
"Content-Type": [
"application/json"
],
"User-Agent": [
"curl/8.7.1"
]
},
"payload": "{ \"name\": \"John Doe\", \"email\": \"[email protected]\" }"
}