network

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockServer

func MockServer(path string, body []byte) (url string, finalizer func())

Types

type DefaultRESTClient

type DefaultRESTClient struct{}

func (*DefaultRESTClient) Do added in v0.7.0

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

func (*DefaultRESTClient) RetrieveBody

func (c *DefaultRESTClient) RetrieveBody(request *Request) ([]byte, error)

func (*DefaultRESTClient) RetrieveHead added in v0.6.0

func (c *DefaultRESTClient) RetrieveHead(url string) (*http.Response, error)

type MockReadCloser added in v0.6.0

type MockReadCloser struct {
	ReadBody []byte

	CloseError error
	// contains filtered or unexported fields
}

func (*MockReadCloser) Close added in v0.6.0

func (mrc *MockReadCloser) Close() error

func (*MockReadCloser) Read added in v0.6.0

func (mrc *MockReadCloser) Read(p []byte) (n int, err error)

type MockReader added in v0.3.0

type MockReader struct{}

func (*MockReader) Read added in v0.3.0

func (m *MockReader) Read(p []byte) (n int, err error)

type RESTClient

type RESTClient interface {
	Do(request *Request) (*http.Response, error)
	RetrieveBody(request *Request) ([]byte, error)
	RetrieveHead(url string) (*http.Response, error)
}

type Request

type Request struct {
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(method, url string, body io.Reader) *Request

func (*Request) SetHeader added in v0.7.0

func (r *Request) SetHeader(key, value string)

type TestRESTClient

type TestRESTClient struct {
	Body         []byte
	Error        error
	StatusCode   int
	DoRequests   []*Request
	Requests     []*Request
	HeadRequests []*string
	HeadResponse *http.Response
}

func (*TestRESTClient) Do added in v0.7.0

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

func (*TestRESTClient) RetrieveBody

func (c *TestRESTClient) RetrieveBody(request *Request) ([]byte, error)

func (*TestRESTClient) RetrieveHead added in v0.6.0

func (c *TestRESTClient) RetrieveHead(url string) (*http.Response, error)

Jump to

Keyboard shortcuts

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