simplehttp

package
v0.0.0-...-6a00723 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package simplehttp is a very simple HTTP client helper library.

Index

Constants

This section is empty.

Variables

View Source
var Client = &http.Client{
	Transport: &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
		}).DialContext,
		ForceAttemptHTTP2:     true,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	},
}

Client is the underlying HTTP client that will be used by Request.

View Source
var RateLimit = rate.NewLimiter(rate.Every(time.Second), 1) // 1 request per second.

RateLimit will be used by Request to ensure we do not overload the servers we use.

View Source
var UserAgent string

UserAgent is the user-agent string that should be provided with requests. If UserAgent is empty, Request will return an error.

Functions

func Request

func Request(req *http.Request) (*http.Response, error)

Request performs the given HTTP request, returning the response.

Types

This section is empty.

Jump to

Keyboard shortcuts

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