http_probe

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 6 Imported by: 0

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select(urls []string, timeout time.Duration, client *http.Client) (string, error)

func SelectURLs added in v0.1.0

func SelectURLs(urls []url.URL, timeout time.Duration, client *http.Client) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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