adapters-nethttp-client

command
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 17 Imported by: 0

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:

  1. Body — POST /users (request body codec, shared-contract pattern)
  2. Path params — GET /users/{id} (codec-validated path variable)
  3. Cookies + headers — GET /profile (CookieParam + HeaderParam validation)
  4. Security — GET /data (CredentialFunc injects bearer Authorization header)
  5. Structured error logging — errors.As + slog for all typed error types

Run with: go run ./examples/adapters-nethttp-client

Directories

Path Synopsis
Package contract defines the shared HTTP API contract for the adapters-nethttp-client example.
Package contract defines the shared HTTP API contract for the adapters-nethttp-client example.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL