Add WithHTTPRequestHook to allow callers to inspect outgoing HTTP requests
and modify request metadata before they are sent to the daemon.
Request hooks receive a clone of the original request so that modifications
made by hooks do not mutate the request passed to the client's RoundTripper.
Changes made by hooks are preserved on the request passed to the underlying
transport.
Protect request bodies while hooks are running, preventing hooks from reading
or closing the body while restoring the original body before the request is
sent. Hooks are invoked in registration order and may return an error to abort
the request.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- Move "Example" tests separate so that we can use the actual import
- Add "WithUserAgent" in the examples, which should be best practice
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use a more idiomatic name so that it can be used as `client.New()`.
We should look if we want `New()` to have different / updated defaults
i.e., enable `WithEnv` as default, and have an opt-out and have API-
version negotiation enabled by default (with an opt-out option).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>