A method chaining HTTP Client for Golang with simple methods
Get, Post, PostJson, PostForm, Put, PutJson, Patch, Delete, Options
package main
import (
"fmt"
"github.com/panwenbin/ghttpclient"
"io/ioutil"
"log"
)
func main() {
response, err := ghttpclient.Get("http://www.panwenbin.com/", nil).Response()
if err != nil {
log.Fatal(err)
}
body, err := ghttpclient.ReadBodyClose(response)
fmt.Printf("%s", body)
}
body, err := ghttpclient.Get("http://www.panwenbin.com/", nil).ReadBodyClose()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", body)
headers := header.GHttpHeader{}
headers.UserAgent("ghttpclient")
response, err := ghttpclient.NewClient().
Url("http://www.panwenbin.com/").
Headers(headers).
Get().Response()
API Reference: https://godoc.org/github.com/panwenbin/ghttpclient