Categorygithub.com/miihael/go-http-probe
modulepackage
0.1.1
Repository: https://github.com/miihael/go-http-probe.git
Documentation: pkg.go.dev

# README

go-http-probe

Run HEAD request to several URLs to select the fastest

Example:

package main


import (
	"flag"
	"log"
	"time"

	"github.com/miihael/go-http-probe"
)

func main() {
	flag.Parse()
	if flag.NArg() < 2 {
		log.Fatalln("Usage: %s url url [url...]")
	}

	url, err := http_probe.Select(flag.Args(), 15*time.Second, nil)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("selected %s", url)
}

Run it:

go get github.com/miihael/go-http-probe

go run example.go

# Functions

No description provided by the author
SelectAll returns URLs and elapsed times in order they have replied.
SelectURLs returns the fastest URL as string from URL objects responded OK within timeout.
SelectURLsIdx returns the index of fastest URL from URL objects responded OK within timeout or -1 if none.
SelectURLsIdxWithContext returns the index of fastest URL from URLs responded OK within timeout or -1 if none.
Select the fastest URL responded OK within timeout.

# Structs

No description provided by the author