https://github.com/koron-go/jsonhttpc
Make it easy to send and receive HTTP requests with JSON bodies
https://github.com/koron-go/jsonhttpc
http-client json
Last synced: 2 months ago
JSON representation
Make it easy to send and receive HTTP requests with JSON bodies
- Host: GitHub
- URL: https://github.com/koron-go/jsonhttpc
- Owner: koron-go
- License: mit
- Created: 2020-02-09T14:28:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2026-03-25T12:34:36.000Z (3 months ago)
- Last Synced: 2026-03-26T15:39:12.228Z (3 months ago)
- Topics: http-client, json
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON-specialized HTTP client
[](https://pkg.go.dev/github.com/koron-go/jsonhttpc)
[](https://github.com/koron-go/jsonhttpc/actions?query=workflow%3AGo)
[](https://goreportcard.com/report/github.com/koron-go/jsonhttpc)
Package jsonhttpc provides a way to easily send and receive HTTP requests with JSON bodies.
* Request and response is encoded/decoded as JSON automatically.
* Bit handy for repeating requests.
* specify base URL - `WithBaseURL()`
* specify HTTP Client - `WithClient()`
* specify HTTP header - `WithHeader()`
* Tips to customize requests - for `Do()`
* `ContentType() string` on `body` overrides "Content-Type" header.
(default is "application/json")
* Responses are automatically JSON-decoded even in case of errors - `Error`
* Most of JSON properties are put into
`Properties map[string]interface{}`
* Error responses that follow [RFC7808 Problem Details for HTTP APIs][rfc7808] are a bit easier to handle.
(Japanese)
* リクエストとレスポンスは自動的にJSONエンコード/デコードされます
* リクエストを繰り返し行うのに少し便利です
* ベースURLを設定できる `WithBaseURL()`
* HTTP Clientを設定できる `WithClient()`
* ヘッダーを設定できる `WithHeader()`
* リクエストをカスタマイズするtipsがあります - for `Do()`
* `body` に `ContentType() string` を実装するとContent-Typeヘッダーを変更
できます (デフォルトは `application/json`)
* エラーの際もレスポンスは自動的にJSONデコードされます
* `Error.Properties` に `map[string]interface{}` で入ります
* [RFC7808 Problem Details for HTTP APIs][rfc7808] は少し楽できます
[rfc7808]:https://tools.ietf.org/html/rfc7807
## Install and update
```console
$ go get github.com/koron-go/jsonhttpc@latest
```
## How to use