fet
github.com/rodkranz/fetch
go get github.com/rodkranz/fetch
fet

github.com/rodkranz/fetch

Golang Fetch

by Rodrigo Lopes

v1.2.0 (see all)License:MIT
go get github.com/rodkranz/fetch
Readme

Build Status Godoc license Go Report Card

Fetch HTTP Client

Simple fetch made in Go to simplify the life of programmer.

About

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.

Install

Default

go get github.com/rodkranz/fetch

Go DEP

dep ensure --add github.com/rodkranz/fetch

Import

import (
  "github.com/rodkranz/fetch"
)

Test

To run the project test

go test -v --cover

Example:

Simple

client := fetch.NewDefault()
response, err := client.Get("http://www.google.com/", nil)

Custom Headers

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)

Simple JSON POST

login := map[string]interface{}{
    "username": "rodkranz",
    "password": "loremIpsum",
}
response, err := fetch.NewDefault().
        IsJSON().
        Post("http://www.google.com/", fetch.NewReader(login))

GitHub Stars

12

LAST COMMIT

2yrs ago

MAINTAINERS

0

CONTRIBUTORS

3

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
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
No alternatives found
No tutorials found
Add a tutorial