An open API service indexing awesome lists of open source software.

https://github.com/blizzy78/gojsonclient

A Go client for JSON/REST HTTP services
https://github.com/blizzy78/gojsonclient

client go golang json rest

Last synced: 5 months ago
JSON representation

A Go client for JSON/REST HTTP services

Awesome Lists containing this project

README

          

[![GoDoc](https://pkg.go.dev/badge/github.com/blizzy78/gojsonclient)](https://pkg.go.dev/github.com/blizzy78/gojsonclient)

gojsonclient
============

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

```go
import "github.com/blizzy78/gojsonclient"
```

Code example
------------

```go
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.