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
- Host: GitHub
- URL: https://github.com/blizzy78/gojsonclient
- Owner: blizzy78
- License: mit
- Created: 2023-12-24T05:46:50.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T16:52:39.000Z (about 2 years ago)
- Last Synced: 2024-04-16T22:05:08.857Z (about 2 years ago)
- Topics: client, go, golang, json, rest
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](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.