Categorygithub.com/Piszmog/httpclient
modulepackage
1.0.4
Repository: https://github.com/piszmog/httpclient.git
Documentation: pkg.go.dev

# README

Go HTTP Client

Build Status Coverage Status Go Report Card GitHub release License: MIT

Simple module for creating HTTP clients with timeouts and connection pool.

Description

Instead of copying and pasting the same snippet of code for creating http.Client with timeouts and connection pools, this module provides a simple package for create a client.

Usage

There are two ways for creating a HTTP client.

Default Client

The function CreateDefaultHttpClient() provides a HTTP client with timeouts set to 5 seconds, keep alive set to 30 seconds, TLS handshake timeout set to 5 seconds, idleConnection timeout set to 90 seconds, max idle connections is 100, and max idle connections per host is 100.

Specific Client

The function CreateHttpClient(timeout, keepAlive, tlsHandshakeTimeout, idleConnection time.Duration, idleConns, idleConnsPerHost int) allows the ability to tweak the specific timeouts and connection pool.

# Functions

CreateDefaultHttpClient creates a default http.Client.
CreateHttpClient creates a http.Client from the specified timeouts and keep alive.
CreateOAuth2Client creates an OAuth2 http.Client from the provided credentials.
CreateOAuth2Config creates an OAuth2 config from the provided credentials.