restclient

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package restclient is an abstration that perform http requests

Package restclient is an abstration that perform http requests

Index

Constants

This section is empty.

Variables

View Source
var (
	// RestClientMockDoFunc is the function that will be called when the mock rest client is used.
	RestClientMockDoFunc func(req *http.Request) (*http.Response, error)
)

Functions

func Delete

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

Delete performs an HTTP DELETE request.

func DeleteWithHeaders

func DeleteWithHeaders(url string, headers map[string]string) (*http.Response, error)

DeleteWithHeaders performs an HTTP DELETE request with headers.

func Get

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

Get performs an HTTP GET request.

func GetWithHeaders

func GetWithHeaders(url string, headers map[string]string) (*http.Response, error)

GetWithHeaders performs an HTTP GET request with headers.

func Init

func Init()

Init initializes the restclient package.

func Post

func Post(url string, body []byte) (*http.Response, error)

Post performs an HTTP POST request.

func PostWithHeaders

func PostWithHeaders(url string, headers map[string]string, body []byte) (*http.Response, error)

PostWithHeaders performs an HTTP POST request with headers.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient defines an HTTP client interface to perform HTTP requests.

var (
	// Client is the http client used to make requests
	Client HTTPClient
)

type Mock

type Mock struct{}

Mock is a mock implementation of the restclient.Client interface.

func (*Mock) Do

func (m *Mock) Do(req *http.Request) (*http.Response, error)

Do is a mock implementation of the restclient.Client.Do function.

Jump to

Keyboard shortcuts

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