Documentation
¶
Overview ¶
Package adapters-nethttp-client demonstrates the HTTP client-side adapter.
go-codex routes are declarative values — the same rest.Route that drives the server (nethttp.Handler / nethttp.Register) can be used on the client (nethttp.Call) to make typed HTTP calls with full codec validation.
The shared contract/ sub-package defines types, codecs, and route specs. Both server and client import it. The Go compiler enforces the contract: any change breaks compilation on both sides immediately — no stale YAML.
The example covers all CallOptions fields in five sections:
- Body — POST /users (request body codec, shared-contract pattern)
- Path params — GET /users/{id} (codec-validated path variable)
- Cookies + headers — GET /profile (CookieParam + HeaderParam validation)
- Security — GET /data (CredentialFunc injects bearer Authorization header)
- Structured error logging — errors.As + slog for all typed error types
Run with: go run ./examples/adapters-nethttp-client
Click to show internal directories.
Click to hide internal directories.