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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-19T09:22:04.000Z (almost 5 years ago)
- Last Synced: 2026-01-17T23:42:12.717Z (6 months ago)
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpc
[](https://travis-ci.com/orisano/httpc)
[](https://codeclimate.com/github/orisano/httpc/maintainability)
[](https://codeclimate.com/github/orisano/httpc/test_coverage)
## How to Use
```go
package main
import (
"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.DefaultClient
user := &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