useragent

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: MIT Imports: 1 Imported by: 0

README

See godoc for details.

Package useragent provides http.RoundTripper wrapper to set User-Agent header on each http request made.

Basic usage:

client := &http.Client{
	Transport: useragent.Set(http.DefaultTransport, "MyRobot/1.0"),
}
resp, err := client.Get("https://...")

Documentation

Overview

Package useragent provides http.RoundTripper wrapper to set User-Agent header on each http request made.

Basic usage:

client := &http.Client{
	Transport: useragent.Set(http.DefaultTransport, "MyRobot/1.0"),
}
resp, err := client.Get("https://...")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(rt http.RoundTripper, agent string) http.RoundTripper

Set wraps provided http.RoundTripper returning a new one that adds given agent as User-Agent header for requests without such header or with empty User-Agent header.

If rt is a *http.Transport, the returned RoundTripper would have Transport's methods visible so they can be accessed after type assertion to required interface.

Types

This section is empty.

Jump to

Keyboard shortcuts

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