httpClient

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 struct {
	*http.Client
}

func New

func New() RestClient

func NewWithClient

func NewWithClient(client *http.Client) RestClient

func (RestClient) Delete

func (r RestClient) Delete(url string) (*http.Response, error)

func (RestClient) DeleteJson

func (r RestClient) DeleteJson(url string, body interface{}) (*http.Response, error)

func (RestClient) Get

func (r RestClient) Get(url string) (*http.Response, error)

func (RestClient) GetAsJson added in v2.0.11

func (r RestClient) GetAsJson(url string, bodyTarget interface{}, responseHandler func(response *http.Response) error) error

GET on the given url to retrieve a json payload Return error when GET is impossible or response can not be decoded to json

func (RestClient) Post

func (r RestClient) Post(url string) (*http.Response, error)

func (RestClient) PostJson

func (r RestClient) PostJson(url string, body interface{}) (*http.Response, error)

func (RestClient) PostMultipart

func (r RestClient) PostMultipart(url string, multipartWriter func(writer *multipart.Writer) error) (*http.Response, error)

PostMultipart performs multipart form post with provided parts. Pay attention that it does NOT close io.Reader's of parts! It is task of caller to close Readers

func (RestClient) Put

func (r RestClient) Put(url string) (*http.Response, error)

func (RestClient) PutJson

func (r RestClient) PutJson(url string, body interface{}) (*http.Response, error)

func (RestClient) WithAuthentication

func (r RestClient) WithAuthentication(tokenSource oauth2.TokenSource) RestClient

func (RestClient) WithTimeout

func (r RestClient) WithTimeout(timeout time.Duration) RestClient

func (RestClient) WithTransport

func (r RestClient) WithTransport(tr http.RoundTripper) RestClient

Jump to

Keyboard shortcuts

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