Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 1.4 KB

README.md

File metadata and controls

54 lines (38 loc) · 1.4 KB

HttpClient

A lightweight HTTP client package for Golang

Installation

# Go Modules
require https://github.com/calvin-puram/httpclient/ghttp

Usage

// Import ghttp into your code.
import "github.com/calvin-puram/httpclient/ghttp"

// Configure the client
// First you need to configure and build the client as you need

reqHeaders := make(http.Header)
reqHeaders.Set("headers-key", "headers-value")

// setting global headers use:
SetHeaders(reqHeaders)
// setting user agent use:
SetUserAgent("user-agent")
// set max ideal connection per host use:
SetMaxIdleConns(5)
//specifies the amount of time to wait for a server's response headers after fully writing the request use:
SetResponseHeaderTimeout(5 * time.Second)
// default false: disable client request timeout use:
SetDisableTimeouts(false)


client := ghttp.NewBuilder().SetHeaders(reqHeaders).SetUserAgent("user-agent").
SetMaxIdleConns(5).SetResponseHeaderTimeout(5 * time.Second)SetDisableTimeouts(false).
Build() // build the client

Making HTTP calls

Take a look at all of the examples folder for more information on how to make http calls