Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mengdu/h3

A simple encapsulation of Golang HTTP client.
https://github.com/mengdu/h3

client h3 http

Last synced: 9 days ago
JSON representation

A simple encapsulation of Golang HTTP client.

Awesome Lists containing this project

README

        

# H3

A simple encapsulation of Golang HTTP client.

```go
package demo

import "fmt"

func main() {
client := h3.New()
client.BaseURL = "https://httpbin.org"

req := client.Req("POST", "/anything")
// application/json
form := h3.Json{}
if err := form.Set(map[string]interface{}{
"a": 1,
"b": []string{"1", "2", "3"},
}); err != nil {
panic(err)
}
req.Body = form.Form()

res, err := client.Do(req)
if err != nil {
panic(err)
}

data := map[string]interface{}{}
if err := res.Json(&data); err != nil {
panic(err)
}
fmt.Printf("%#v\n", data)
}
```

[More examples](./examples/)