fastesturl

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastestURL

type FastestURL struct {
	// an http client to use for all requests
	Client *http.Client
	// a list of urls we will concurrecntly attempt to request
	URLs []*url.URL
	// a template request object we will copy fields from
	Request *http.Request
	// a function provided by the caller to determine if a request
	// should be returned
	RespCheck RespCheck
}

FatestURL implements a method for obtaining the first *http.Response object returned from a list of URLs.

func New

func New(client *http.Client, req *http.Request, check RespCheck, urls []*url.URL) *FastestURL

New is a constructor for a FastestURL

func (*FastestURL) Do

func (f *FastestURL) Do(ctx context.Context) *http.Response

Do will return the first *http.Response which passes f.RespCheck.

If no successful *http.Response is obtained a nil is returned. Any timeout or cancellation must be provided by the caller.

type RespCheck

type RespCheck func(*http.Response) bool

ReqCheckFunc checks if a *http.Response is valid for returning to a client

Jump to

Keyboard shortcuts

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