request

package
v0.0.0-...-b7543ad Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentType

func ContentType(contentType string) func(*Options)

ContentType sets the specified Content-Type request header

func DaemonHost

func DaemonHost() string

DaemonHost return the daemon host string for this test execution

func DaemonTime

func DaemonTime(ctx context.Context, t testing.TB, client client.APIClient, testEnv *environment.Execution) time.Time

DaemonTime provides the current time on the daemon host

func DaemonUnixTime

func DaemonUnixTime(ctx context.Context, t testing.TB, client client.APIClient, testEnv *environment.Execution) string

DaemonUnixTime returns the current time on the daemon host with nanoseconds precision. It return the time formatted how the client sends timestamps to the server.

func Delete

func Delete(ctx context.Context, endpoint string, modifiers ...func(*Options)) (*http.Response, io.ReadCloser, error)

Delete creates and execute a DELETE request on the specified host and endpoint, with the specified request modifiers

func Do

func Do(ctx context.Context, endpoint string, modifiers ...func(*Options)) (*http.Response, io.ReadCloser, error)

Do creates and execute a request on the specified endpoint, with the specified request modifiers

func Get

func Get(ctx context.Context, endpoint string, modifiers ...func(*Options)) (*http.Response, io.ReadCloser, error)

Get creates and execute a GET request on the specified host and endpoint, with the specified request modifiers

func Head(ctx context.Context, endpoint string, modifiers ...func(*Options)) (*http.Response, io.ReadCloser, error)

Head creates and execute a HEAD request on the specified host and endpoint, with the specified request modifiers

func Host

func Host(host string) func(*Options)

Host creates a modifier that sets the specified host as the request URL host

func JSON

func JSON(o *Options)

JSON sets the Content-Type request header to json

func JSONBody

func JSONBody(data interface{}) func(*Options)

JSONBody creates a modifier that encodes the specified data to a JSON string and set it as request body. It also sets the Content-Type header of the request.

func Method

func Method(method string) func(*Options)

Method creates a modifier that sets the specified string as the request method

func NewAPIClient

func NewAPIClient(t testing.TB, ops ...client.Opt) client.APIClient

NewAPIClient returns a docker API client configured from environment variables

func Post

func Post(ctx context.Context, endpoint string, modifiers ...func(*Options)) (*http.Response, io.ReadCloser, error)

Post creates and execute a POST request on the specified host and endpoint, with the specified request modifiers

func RawContent

func RawContent(reader io.ReadCloser) func(*Options)

RawContent sets the specified reader as body for the request

func RawString

func RawString(content string) func(*Options)

RawString sets the specified string as body for the request

func ReadBody

func ReadBody(b io.ReadCloser) ([]byte, error)

ReadBody read the specified ReadCloser content and returns it

func SockConn

func SockConn(timeout time.Duration, daemon string) (net.Conn, error)

SockConn opens a connection on the specified socket

func With

func With(f func(*http.Request) error) func(*Options)

With adds a request modifier to the options

Types

type Options

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

Options defines request options, like request modifiers and which host to target

Jump to

Keyboard shortcuts

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