transport

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHost is the default Host.
	DefaultHost string = "https://<your_org>.tmc.cloud.vmware.com"
	// DefaultBasePath is the default BasePath.
	DefaultBasePath string = "/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*Config
	// contains filtered or unexported fields
}

Client is the http client implementation.

func NewClient

func NewClient(config *proxy.TLSConfig) (*Client, error)

NewClient returns a new instance of http Client.

func NewClientWithDefaultTransport added in v1.1.4

func NewClientWithDefaultTransport() *Client

NewClientWithDefaultTransport is intended primarily for testing, as httpmock requires a default transport object be used.

func (*Client) Create

func (c *Client) Create(url string, request Request, response Response) error

func (*Client) Delete

func (c *Client) Delete(url string) error

func (*Client) Do

func (c *Client) Do(request *http.Request) (*http.Response, error)

Do makes an HTTP request with the native `http.Do` interface.

func (*Client) Get

func (c *Client) Get(url string, response Response) error

func (*Client) Patch added in v1.1.0

func (c *Client) Patch(url string, request Request, response Response) error

func (*Client) Update

func (c *Client) Update(url string, request Request, response Response) error

type Config

type Config struct {
	Host           string
	BasePath       string
	Headers        http.Header
	RefreshAuthCtx func() (map[string]string, error)
}

Config contains the transport related info.

func DefaultTransportConfig

func DefaultTransportConfig() *Config

DefaultTransportConfig creates a Config with default values.

func (*Config) AddHeaders

func (cfg *Config) AddHeaders(header http.Header) *Config

WithHeader overrides the default header.

func (*Config) WithBasePath

func (cfg *Config) WithBasePath(basePath string) *Config

WithBasePath overrides the default basePath.

func (*Config) WithHost

func (cfg *Config) WithHost(host string) *Config

WithHost overrides the default host.

func (*Config) WithRefreshAuthCtx added in v1.2.0

func (cfg *Config) WithRefreshAuthCtx(refresh func() (map[string]string, error)) *Config

WithRefreshAuthCtx overrides the default RefreshAuthCtx.

type Request

type Request interface {
	MarshalBinary() ([]byte, error)
}

type Response

type Response interface {
	UnmarshalBinary(b []byte) error
}

Jump to

Keyboard shortcuts

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