Prerequisites
Before you begin, prepare:- a trusted server runtime and application authentication boundary;
- a disposable personal workspace Praxa key with only the tutorial’s required scopes;
- synthetic input plus a persisted application request ID for replay tests;
- a fake upstream for unit tests and a non-production environment for canaries;
- an acceptance assertion that proves the reusable reqwest client preserves authority, deadlines, replay, and redacted failures.
1. Add dependencies
Cargo.toml
2. Create a reusable client
src/praxa.rs
reqwest::Client so requests share connection pooling. Do not create
a new client inside every handler.
3. Call it from your server handler
Your Axum, Actix Web, or Rocket handler should:- authenticate the application caller;
- derive
user_idfrom that principal; - validate
logical_request_idandinput; - call
submit_task; - return a customer-safe projection with
Cache-Control: no-store.
4. Test with a mock server
Point a test-only client at an injected origin, then assert:- authorization and idempotency headers are present upstream;
- the same user and request ID produce the same key;
- different users produce different keys;
- invalid input makes zero upstream calls;
401,403,409, and429stay distinguishable;- error bodies are not reflected to untrusted callers.
5. Verify live behavior
Use a disposable key withexecute:write and runs:read. Submit one task,
read /v1/runs/{id} until terminal, then revoke the key. Repeat an exact
request with the same logical ID and require the same logical run.
Troubleshooting
Best practices
- Reuse the HTTP client.
- Bound connect, request, and overall operation time.
- Make authority types distinct from request-body types.
- Redact response bodies before logging.
- Preserve the body digest and key for reconciliation.
- Use
rustlsor your reviewed TLS backend; never disable certificate checks.
reqwest client
Review current timeout, TLS, header, and connection-pooling options in the
reqwest reference.
Optimize for production
- Reuse one configured HTTP or SDK client per process and bound concurrent upstream work.
- Prefer durable admission plus asynchronous readback over holding application requests open.
- Cache only non-sensitive, tenant-scoped reads within their documented freshness window.
- Measure p50/p95 latency, admission-to-terminal time, retries, conflicts, and connection reuse before tuning.
Cleanup and next steps
- Revoke the disposable Praxa key and require a later request to fail.
- Remove synthetic application records and any temporary environment files.
- Cancel or archive unresolved test runs according to the application policy.
- Retain only redacted request, run, and verification identifiers needed for the test record.