Go HTTP Client that prevents you from having to write boilerplate code setting up a native *http.Client
, creating a request, and parsing the response. This package uses the builder pattern for constructing requests and parsing responses.
package main
import (
"fmt"
"github.com/hypnobrando/sendy"
)
type (
User struct {
ID int `json:"id"`
Name string `json:"name"`
}
)
func main() {
var user User
err := sendy.
Get("https://myapi.com/users/1").
SendIt().
JSON(&user).
Error()
if err != nil {
panic(err)
}
fmt.Println(user)
}
To install sendy
, use go get
:
go get github.com/hypnobrando/sendy
Import the hypnobrando/sendy
package into your code:
import "github.com/hypnobrando/sendy"
func main() {
httpClient := sendy.NewClient()
}
To update sendy
to the latest version, use go get -u github.com/hypnobrando/sendy
.
Please feel free to submit issues, fork the repository and send pull requests!