Skip to content

Run Echo Upstream

Echo Upstream is a zero-dependency HTTP service under examples/echoUpstream. It stands in for the API you would put behind Caracal, so you can verify a Gateway-mediated request end to end without hosting your own upstream. Every response states whether the call was brokered by the Gateway or hit the service directly, and shows the evidence behind that verdict.

AreaBehavior
Brokered-call proofReports viaGateway plus the request ID, trace context, and forwarding metadata the Gateway stamped on the request.
Credential handlingConfirms the Gateway injected the brokered credential and redacts credential values from the echoed headers.
Gateway reachabilityJoins the caracalData Docker network so Gateway can reach http://echoUpstream:8088.
Local debuggingExposes http://127.0.0.1:8088 on the host and logs one line per request, marked [gateway] or [direct].
Terminal window
cd examples/echoUpstream
docker compose -f compose.yml up --build

Check the local health endpoint:

Terminal window
curl http://127.0.0.1:8088/healthz
Terminal window
cd examples/echoUpstream
npm start

The server listens on port 8088. Set ECHO_PORT when you need a different local port.

In Console guided setup or through the Control API, create a resource with this upstream URL:

http://echoUpstream:8088

Then send a request to the Gateway with the Caracal access token and resource ID from guided setup. The Console result view prints the exact command for your setup; it has this shape:

Terminal window
curl http://localhost:8081/v1/hello \
-H "Authorization: Bearer $CARACAL_RESOURCE_PIPERNET_TOKEN" \
-H "X-Caracal-Resource: resource://pipernet"

A brokered call returns "viaGateway": true with a gateway section:

FieldWhat it proves
viaGatewayThe request carried the Gateway’s request ID and forwarding metadata.
gateway.requestIdAudit handle — paste it into Console explain to trace the policy decision.
gateway.credentialInjectedThe Gateway brokered a credential the client never held.
request.headersThe headers the upstream actually received, with credentials redacted.

Calling http://127.0.0.1:8088/ directly returns "viaGateway": false, which makes the difference between a protected and an unprotected path visible.

Terminal window
cd examples/echoUpstream
npm test

Continue to Bootstrap Control State when you want repeatable setup for demo resources and policies.