httpua

package module
v0.0.0-...-ad59cd5 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2022 License: MIT Imports: 1 Imported by: 0

README

httpua

A Go package to set a custom User-Agent when placing HTTP requests using http.Client.

Usage

Creating a new http client:

client := httpua.NewClient("MyUserAgent/1.0") // Returns *http.Client
client.Get("...")

Extending an initialized http client:

client := httpua.WithClient(http.DefaultClient, "MyUserAgent/1.0") // Returns *http.Client
client.Get("...")

Documentation

https://pkg.go.dev/github.com/adamkeys/httpua

Documentation

Overview

Package httpua provides a HTTP client that sends a custom User-Agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(userAgent string) *http.Client

NewClient returns a new http.Client that is initialized to send the supplied userAgent string for the User-Agent header.

func WithClient

func WithClient(client *http.Client, userAgent string) *http.Client

WithClient is similar to NewClient but returns a new http.Client copied from the supplied http.Client that is initialized to send the supplied userAgent string for the User-Agent header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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