Migration: secure HTTP client → go/httpclient¶
The hardened HTTP client factory — NewClient, NewTransport, the redirect
policy, and the WithTimeout / WithMaxRedirects / WithTLSConfig /
WithTransport / WithCertPool / WithRetry / WithClientMiddleware options —
has been extracted out of go-tool-base into the standalone module
gitlab.com/phpboyscout/go/httpclient (v0.1.0). It is framework-free: it
depends only on go/tls for the hardened TLS
defaults and go/transit for the retry
transport and client middleware chain — no GTB, no gRPC SDK, no config
container.
What changed¶
- Nothing changes for GTB consumers.
pkg/httpstill exists and its public API is identical. The client factory is now a thin facade that re-exports thego/httpclientsymbols (value aliases), so every existing call site —gtbhttp.NewClient(...),WithTimeout,WithRetry,WithClientMiddleware,NewTransport,WithCertPool, and the rest — resolves exactly as before. - The retry/middleware types the options consume (
RetryConfig,ClientChain) are re-exported fromgo/transitand are type-identical to the types the module's options expect, so mixed usage (WithRetry(gtbhttp.RetryConfig{...})) keeps compiling. - The GTB-specific pieces stay in go-tool-base: the config-key adapters, the
server bootstraps (
NewServer/Register), request authentication and security headers.
How to migrate¶
If you consume go-tool-base's pkg/http client factory, do nothing — upgrade
as usual and your imports keep working.
If you want the hardened client without the framework, depend on the module directly:
go get gitlab.com/phpboyscout/go/[email protected]
import (
"gitlab.com/phpboyscout/go/httpclient"
transithttp "gitlab.com/phpboyscout/go/transit/http"
)
client := httpclient.NewClient(
httpclient.WithTimeout(10*time.Second),
httpclient.WithRetry(transithttp.DefaultRetryConfig()),
)
The module's WithRetry / WithClientMiddleware take go/transit types
directly (transithttp.RetryConfig, transithttp.ClientChain) rather than GTB
re-exports — the only visible difference from the pkg/http facade.
Notes¶
- Full documentation and the factory model live at httpclient.go.phpboyscout.uk; the API reference is on pkg.go.dev.