httpClient

package
v2.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRestClient added in v2.20.0

func ContextWithRestClient(ctx context.Context, client RestClient) context.Context

func ExtractHeader added in v2.0.11

func ExtractHeader(res *http.Response, target string) ([]string, error)

Extract the given http header values Return error when the given http header was not found

Types

type RestClient

type RestClient interface {
	RestClientDelete
	RestClientGet
	RestClientPost
	RestClientPut
	WithBearerTokenAuthentication(tokenSource oauth2.TokenSource) RestClient
	WithBasicAuthentication(user string, password string) RestClient
	WithHeader(key, value string) RestClient
	WithTransport(tr http.RoundTripper) RestClient
	WithTimeout(timeout time.Duration) RestClient
}

func FromContext added in v2.20.0

func FromContext(ctx context.Context) RestClient

FromContext returns the previously set context or creates a new one

func New

func New() RestClient

func NewWithClient

func NewWithClient(client *http.Client) RestClient

type RestClientDelete added in v2.4.2

type RestClientDelete interface {
	Delete(ctx context.Context, url string) (*http.Response, error)
	DeleteJson(ctx context.Context, url string, body interface{}) (*http.Response, error)
}

type RestClientGet added in v2.4.2

type RestClientGet interface {
	Get(ctx context.Context, url string) (*http.Response, error)
	GetAsJson(ctx context.Context, url string, bodyTarget interface{}, responseHandler func(response *http.Response) error) error
}

type RestClientPost added in v2.4.2

type RestClientPost interface {
	Post(ctx context.Context, url string) (*http.Response, error)
	PostJson(ctx context.Context, url string, body interface{}) (*http.Response, error)
	PostMultipart(ctx context.Context, url string, multipartWriter func(writer *multipart.Writer) error) (*http.Response, error)
	PostMultipartChunked(ctx context.Context, url string, multipartWriter func(writer *multipart.Writer)) (*http.Response, error)
}

type RestClientPut added in v2.4.2

type RestClientPut interface {
	Put(ctx context.Context, url string) (*http.Response, error)
	PutJson(ctx context.Context, url string, body interface{}) (*http.Response, error)
}

Jump to

Keyboard shortcuts

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