Documentation
¶
Overview ¶
Package client provides a convenience Client that resolves URL schemes to transport implementations and provides Handshake/Connect methods.
Index ¶
- Constants
- type Client
- type HTTPAuth
- type Option
- func WithCABundle(pem []byte) Option
- func WithDialer(fn transport.DialContextFunc) Option
- func WithHTTPAuth(a HTTPAuth) Option
- func WithHTTPClient(c *http.Client) Option
- func WithInsecureSkipTLS() Option
- func WithLoader(l transport.Loader) Option
- func WithProxyEnvironment() Option
- func WithProxyURL(u *url.URL) Option
- func WithRedirectPolicy(policy RedirectPolicy) Option
- func WithSSHAuth(a SSHAuth) Option
- func WithTransport(scheme string, tr transport.Transport) Option
- type RedirectPolicy
- type SSHAuth
Constants ¶
const ( // FollowInitialRedirects follows redirects only for the initial // /info/refs discovery request. FollowInitialRedirects = xhttp.FollowInitialRedirects // FollowRedirects follows redirects for all requests. FollowRedirects = xhttp.FollowRedirects // NoFollowRedirects disables redirects for all requests. NoFollowRedirects = xhttp.NoFollowRedirects )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client resolves URL schemes to transport implementations.
func New ¶
New creates a Client with built-in transports for file, git, ssh, http, and https schemes. Options customize authentication, proxying, dialing, and transport overrides.
func (*Client) Connect ¶
Connect resolves the transport for the request URL scheme and opens a raw full-duplex connection. Returns ErrConnectUnsupported if the transport does not implement Connector (e.g. HTTP).
type HTTPAuth ¶
HTTPAuth is implemented by HTTP authentication types whose Authorizer method can be used to mutate outgoing HTTP requests.
type Option ¶
type Option func(*options)
Option configures a Client.
func WithCABundle ¶
WithCABundle sets a PEM-encoded CA certificate bundle for HTTPS connections. When set, only these CAs are trusted. Can be combined with WithInsecureSkipTLS.
func WithDialer ¶
func WithDialer(fn transport.DialContextFunc) Option
WithDialer sets a custom dialer for SSH and Git TCP transports.
func WithHTTPAuth ¶
WithHTTPAuth sets HTTP authentication. The auth type's Authorizer method is called for each outgoing HTTP request.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used by the HTTP transport. When a custom client is set, WithInsecureSkipTLS, WithCABundle, and WithProxyURL/WithProxyEnvironment do not affect HTTP connections — configure them on the provided client directly.
func WithInsecureSkipTLS ¶
func WithInsecureSkipTLS() Option
WithInsecureSkipTLS disables TLS certificate verification for HTTPS. Can be combined with WithCABundle.
func WithLoader ¶
WithLoader sets the storage loader for the file transport.
func WithProxyEnvironment ¶
func WithProxyEnvironment() Option
WithProxyEnvironment honors standard proxy environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY) for all transports. For HTTP, this uses http.ProxyFromEnvironment. For SSH and Git TCP, this uses golang.org/x/net/proxy.FromEnvironmentUsing.
func WithProxyURL ¶
WithProxyURL routes all transport connections through the given proxy URL. For HTTP, this uses http.ProxyURL. For SSH and Git TCP, this uses golang.org/x/net/proxy.FromURL to wrap the underlying dialer.
func WithRedirectPolicy ¶
func WithRedirectPolicy(policy RedirectPolicy) Option
WithRedirectPolicy sets the HTTP redirect policy. If unset, the HTTP transport defaults to FollowInitialRedirects.
func WithSSHAuth ¶
WithSSHAuth sets SSH authentication. The auth type's ClientConfig method is called for each SSH connection.
type RedirectPolicy ¶
type RedirectPolicy = xhttp.RedirectPolicy
RedirectPolicy controls how HTTP transports follow redirects.