Simple fetch made in Go to simplify the life of programmer.
Go’s http package doesn’t specify request timeouts by default, allowing services to hijack your goroutines. Always specify a custom http.Client when connecting to outside services.
Default
go get github.com/rodkranz/fetch
dep ensure --add github.com/rodkranz/fetch
import (
"github.com/rodkranz/fetch"
)
To run the project test
go test -v --cover
client := fetch.NewDefault()
response, err := client.Get("http://www.google.com/", nil)
opt := fetch.Options{
Header: http.Header{
"Content-Type": []string{"application/json"},
"User-Agent": []string{"XPTO-Agent-user"},
},
}
f := fetch.New(&opt)
rsp, err := f.GetWithContext(context.Background(), "http://www.google.com", nil)
login := map[string]interface{}{
"username": "rodkranz",
"password": "loremIpsum",
}
response, err := fetch.NewDefault().
IsJSON().
Post("http://www.google.com/", fetch.NewReader(login))
Version | Tag | Published |
---|---|---|
v0.0.0-20180823095855-a12b3bb1711a | 2yrs ago | |
v1.2.0 | 2yrs ago | |
v0.0.0-20200206220250-024ad86a0de4 | 2yrs ago | |
v0.0.0-20180823105522-b6eb8fd7ec24 | 3yrs ago |