target

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRoundTripper http.RoundTripper = &http.Transport{
	Proxy:             http.ProxyFromEnvironment,
	DisableKeepAlives: true,
}

DefaultRoundTripper is our default RoundTripper.

Functions

This section is empty.

Types

type BasicAuthTransport

type BasicAuthTransport struct {
	Transport http.RoundTripper
	Username  string
	Password  string
}

BasicAuthTransport is the struct to add basic auth to a RoundTripper.

func (BasicAuthTransport) RoundTrip

func (bat BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTrip for our RoundTripper with basic auth support.

type Client

type Client interface {
	Start()
	Name() string
	Results() []Result
	LastResult() Result
}

func NewClient

func NewClient(config Config) Client

type Config

type Config struct {
	Name                  string        `yaml:"name"`
	URL                   string        `yaml:"url"`
	Method                string        `yaml:"method"`
	Body                  string        `yaml:"body"`
	Username              string        `yaml:"username"`
	Password              string        `yaml:"password"`
	Token                 string        `yaml:"token"`
	Notification          bool          `yaml:"notification"`
	NotificationThreshold time.Duration `yaml:"notificationThreshold"`
	Interval              time.Duration `yaml:"interval"`
	Timeout               time.Duration `yaml:"timeout"`
}

type Result

type Result struct {
	StatusCode int

	DNSLookup        time.Duration
	TCPConnection    time.Duration
	TLSHandshake     time.Duration
	ServerProcessing time.Duration
	ContentTransfer  time.Duration

	NameLookup    time.Duration
	Connect       time.Duration
	Pretransfer   time.Duration
	StartTransfer time.Duration
	Total         time.Duration
	// contains filtered or unexported fields
}

See https://github.com/tcnksm/go-httpstat

func (*Result) End

func (r *Result) End(t time.Time, statusCode int)

func (*Result) StartTime

func (r *Result) StartTime() time.Time

type TokenAuthTransporter

type TokenAuthTransporter struct {
	Transport http.RoundTripper
	Token     string
}

TokenAuthTransporter is the struct to add token auth to a RoundTripper.

func (TokenAuthTransporter) RoundTrip

func (tat TokenAuthTransporter) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTrip for our RoundTripper with token auth support.

Jump to

Keyboard shortcuts

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