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.
Click to show internal directories.
Click to hide internal directories.