timeouthttp

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2019 License: MIT Imports: 3 Imported by: 24

README

go-timeout-httpclient

Yet another HTTP Client with configurable timeouts

Usage


import "github.com/pteich/go-timeout-httpclient"

httpClient := timeouthttp.NewClient(timeouthttp.Config{
    RequestTimeout: 5,
    ConnectTimeout: 5,
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPooledTransport

func DefaultPooledTransport(config Config) *http.Transport

func DefaultTransport

func DefaultTransport(config Config) *http.Transport

func NewClient

func NewClient(config Config) *http.Client

NewClient returns a new clean HTTP.Client with timeouts (default 1s for connection and request), disabled idle connections and disabled keep-alives

func NewPooledClient

func NewPooledClient(config Config) *http.Client

NewPooledClient returns a new clean HTTP.Client with timeouts (default 1s for connection and request) and shared transport across hosts with keepalive on, you can set the number of idle connections per host with Config.MaxIdleConnsPerHost (default 1)

Types

type Config

type Config struct {
	ConnectTimeout            int
	RequestTimeout            int
	KeepAliveTimeout          int
	MaxIdleConnectionsPerHost int
}

Config defines timeouts and max idle connections per host if pooled transport is used all timeouts are seconds

Jump to

Keyboard shortcuts

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