Skip to content

blizzy78/gojsonclient

Repository files navigation

GoDoc

gojsonclient

A Go package that provides a client for JSON/REST HTTP services, with automatic retry/backoff.

import "github.com/blizzy78/gojsonclient"

Code example

type request struct {
	Message string `json:"message"`
}

type response struct {
	Reply string `json:"reply"`
}

client := gojsonclient.New()

req := gojsonclient.NewRequest[*request, *response](
	"https://www.example.com",
	http.MethodGet,
	&request{Message: "client"},
)

res, _ := gojsonclient.Do(context.Background(), client, req)
fmt.Println(res.Res.Reply)

// Output: Hello client!

License

This package is licensed under the MIT license.