connectors

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserAgent

func GetUserAgent() string

Types

type Connector

type Connector interface {
	Request() (io.ReadCloser, error)
}

type HttpAuthenticator

type HttpAuthenticator interface {
	Authenticate(connector *HttpConnector, req *http.Request) error
}

type HttpBodyBuilder

type HttpBodyBuilder func() (any, error)

type HttpConnector

type HttpConnector struct {
	Method        string
	Url           string
	UserAgent     string
	Headers       map[string]string
	Body          any
	Authenticator HttpAuthenticator
	Timeout       time.Duration
}

func NewHttpGetConnector

func NewHttpGetConnector(url string) *HttpConnector

Build and Connector for HTTP GET requests.

func NewHttpPostConnector

func NewHttpPostConnector(
	url string,
	body any,
) *HttpConnector

Build and Connector for HTTP POST requests.

func (*HttpConnector) Request

func (c *HttpConnector) Request() (io.ReadCloser, error)

func (*HttpConnector) RequestBytes

func (c *HttpConnector) RequestBytes() ([]byte, error)

func (*HttpConnector) RequestString

func (c *HttpConnector) RequestString() (string, error)

func (*HttpConnector) SetAuthenticator

func (c *HttpConnector) SetAuthenticator(authenticator HttpAuthenticator)

func (*HttpConnector) SetBody

func (c *HttpConnector) SetBody(body any)

func (*HttpConnector) SetHeaders

func (c *HttpConnector) SetHeaders(headers map[string]string)

func (*HttpConnector) SetMethod

func (c *HttpConnector) SetMethod(method string)

func (*HttpConnector) SetTimeout

func (c *HttpConnector) SetTimeout(timeout time.Duration)

func (*HttpConnector) SetUrl

func (c *HttpConnector) SetUrl(url string)

func (*HttpConnector) SetUserAgent

func (c *HttpConnector) SetUserAgent(userAgent string)

Jump to

Keyboard shortcuts

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