GiienaAstrella/zei

Go HTTP Client library built atop the standard library's net/http.Client.

★ 0Forks 0GoGitHub ↗Compare
golanggolang-libraryhttphttp-client

README

Zei

Go HTTP Client library built atop the standard library's net/http.Client.

Install

go get -u github.com/ghifari160/zei

Usage

Documentation

Quick Start

package main

import "github.com/ghifari160/zei"

func main() {
	client := zei.New(&zei.Config{})
	resp, err := client.Get("http://example.com/")
	if err != nil {
		// Handle error
	}
	defer resp.Body.Close()
	// ...
}

Set user agent

client := zei.New(&zei.Config{UserAgent: "App/1.0"})
resp, err := client.Get("http://example.com/")

Set timeout

client := zei.New(&zei.Config{Timeout: 1 * time.Minute})
resp, err := client.Get("http://example.com/")

Set authorization

config := zei.Config{}
// Basic Authentication
config.SetBasicAuth("username", "password")
// Bearer Authentication
config.SetBearerAuth("token_value")

client := zei.New(&config)
resp, err := client.Get("http://example.com/")

Contributors

GiienaAstrella

Issues