http

package
v1.1.55 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeout = 10 * time.Second
)

Functions

This section is empty.

Types

type HttpRequestor

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

HttpRequestor implements the Requestor interface

func (*HttpRequestor) DoRequest

func (r *HttpRequestor) DoRequest(ctx context.Context, method, url string, options RequestOptions) (RequestResponse, error)

DoRequest executes and parsed the response of an http request The context passed in will be used for request timeouts, UNLESS there is no timeout set, at which point the default will be used.

type RequestOptions

type RequestOptions struct {
	Body    []byte
	Headers http.Header
	Cookies []*http.Cookie
}

RequestOptions is the data to configure an http request sent by a Requestor

type RequestResponse

type RequestResponse struct {
	Body        []byte
	ContentType string
	StatusCode  int
	Headers     http.Header
}

RequestResponse is the data returned by a Requestor

type Requestor

type Requestor interface {
	DoRequest(ctx context.Context, method, url string, options RequestOptions) (RequestResponse, error)
}

Requestor is an interface for making http requests

func NewRequestor

func NewRequestor(c *http.Client) Requestor

NewRequestor returns a Requestor with a default client if one is not passed

Jump to

Keyboard shortcuts

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