Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orisano/httpc
utilities for http request.
https://github.com/orisano/httpc
Last synced: 24 days ago
JSON representation
utilities for http request.
- Host: GitHub
- URL: https://github.com/orisano/httpc
- Owner: orisano
- License: mit
- Created: 2017-10-23T11:50:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-19T09:22:04.000Z (about 3 years ago)
- Last Synced: 2024-10-04T17:51:24.994Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpc
[![Build Status](https://travis-ci.com/orisano/httpc.svg?branch=master)](https://travis-ci.com/orisano/httpc)
[![Maintainability](https://api.codeclimate.com/v1/badges/2c91b8e3d8b367c2400c/maintainability)](https://codeclimate.com/github/orisano/httpc/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/2c91b8e3d8b367c2400c/test_coverage)](https://codeclimate.com/github/orisano/httpc/test_coverage)## How to Use
```go
package mainimport (
"context"
"io"
"log"
"net/http"
"os""github.com/orisano/httpc"
)type User struct {
ID string
Password string
Age int
}func main() {
rb, err := httpc.NewRequestBuilder("http://api.example/", nil)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
client := http.DefaultClientuser := &User{
ID: "john",
Password: "foobar",
Age: 28,
}req, err := rb.NewRequest(ctx, http.MethodPost, "/v1/users", httpc.WithJSON(user))
if err != nil {
log.Fatal(err)
}
resp, err := httpc.Retry(client, req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
}
```## Author
Nao Yonashiro (@orisano)## License
MIT