Categorygithub.com/richarticle/hclient
repositorypackage
1.0.0
Repository: https://github.com/richarticle/hclient.git
Documentation: pkg.go.dev

# README

HClient

A simple HTTP Client library for Go.

Usage

Import hclient into your code.

import "github.com/richarticle/hclient"

Simple GET

resp, err := hclient.Get("https://www.google.com")

Create a new client

hc := hclient.New(WithTimeout(time.Second*100), WithInsecureSkipVerify(), WithBasicAuth("username", "password"))
resp.err := hc.Get("https://myweb.com")

JSON Request

req := &struct {
	Name string `json:"name"`
	Age uint32  `json:"age"`
}{}

resp := &struct {
	ErrorCode string `json:"error_code"`
}{}

status, err := hclient.DoJSON("POST", "https://myrest.com/api/v1/users", req, resp)