Skip to content

Commit a12d015

Browse files
committed
docs: cleanup
1 parent d231b17 commit a12d015

59 files changed

Lines changed: 192 additions & 366 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 64 additions & 122 deletions
Large diffs are not rendered by default.

client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,16 @@ func OptionsCtx[T any](client *Client, ctx context.Context, url string, opts ...
456456
// r.Method = http.MethodGet
457457
//
458458
// res, rawResp, err := httpx.Do[map[string]any](r)
459+
// if err != nil {
460+
// return
461+
// }
459462
// httpx.Dump(res) // dumps map[string]any
460463
// // #map[string]interface {} {
461464
// // headers => #map[string]interface {} {
462465
// // X-Trace => "1" #string
463466
// // }
464467
// // }
465-
// _ = rawResp
466-
// _ = err
468+
// println(rawResp.StatusCode)
467469
func Do[T any](r *req.Request) (T, *req.Response, error) {
468470
var out T
469471

dump.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ var dumpDumper = godump.NewDumper(godump.WithoutHeader())
99
//
1010
// Example: dump a response
1111
//
12-
// res, err := httpx.Get[map[string]any](httpx.Default(), "https://httpbin.org/uuid")
13-
// _ = err
12+
// res, _ := httpx.Get[map[string]any](httpx.Default(), "https://httpbin.org/uuid")
1413
// httpx.Dump(res)
1514
// // #map[string]interface {} {
1615
// // uuid => "<uuid>" #string

examples/asfirefox/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ func main() {
1010

1111
// Example: use a Firefox profile
1212
c := httpx.New(httpx.AsFirefox())
13-
res, err := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
14-
_ = err
13+
res, _ := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
1514
httpx.Dump(res) // dumps map[string]any
1615
// #map[string]interface {} {
1716
// headers => #map[string]interface {} {

examples/auth/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ func main() {
1111
// Example: custom auth scheme
1212
// Apply to all requests
1313
c := httpx.New(httpx.Auth("Token", "abc123"))
14-
res, err := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
15-
_ = err
14+
res, _ := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
1615
httpx.Dump(res) // dumps map[string]any
1716
// #map[string]interface {} {
1817
// headers => #map[string]interface {} {
@@ -21,8 +20,7 @@ func main() {
2120
// }
2221

2322
// Apply to a single request
24-
res, err = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Auth("Token", "abc123"))
25-
_ = err
23+
res, _ = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Auth("Token", "abc123"))
2624
httpx.Dump(res) // dumps map[string]any
2725
// #map[string]interface {} {
2826
// headers => #map[string]interface {} {

examples/baseurl/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ func main() {
1010

1111
// Example: client base URL
1212
c := httpx.New(httpx.BaseURL("https://httpbin.org"))
13-
res, err := httpx.Get[map[string]any](c, "/uuid")
14-
_ = err
13+
res, _ := httpx.Get[map[string]any](c, "/uuid")
1514
httpx.Dump(res) // dumps map[string]any
1615
// #map[string]interface {} {
1716
// uuid => "<uuid>" #string

examples/basic/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ func main() {
1111
// Example: basic auth
1212
// Apply to all requests
1313
c := httpx.New(httpx.Basic("user", "pass"))
14-
res, err := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
15-
_ = err
14+
res, _ := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
1615
httpx.Dump(res) // dumps map[string]any
1716
// #map[string]interface {} {
1817
// headers => #map[string]interface {} {
@@ -21,8 +20,7 @@ func main() {
2120
// }
2221

2322
// Apply to a single request
24-
res, err = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Basic("user", "pass"))
25-
_ = err
23+
res, _ = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Basic("user", "pass"))
2624
httpx.Dump(res) // dumps map[string]any
2725
// #map[string]interface {} {
2826
// headers => #map[string]interface {} {

examples/bearer/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ func main() {
1111
// Example: bearer auth
1212
// Apply to all requests
1313
c := httpx.New(httpx.Bearer("token"))
14-
res, err := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
15-
_ = err
14+
res, _ := httpx.Get[map[string]any](c, "https://httpbin.org/headers")
1615
httpx.Dump(res) // dumps map[string]any
1716
// #map[string]interface {} {
1817
// headers => #map[string]interface {} {
@@ -21,8 +20,7 @@ func main() {
2120
// }
2221

2322
// Apply to a single request
24-
res, err = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Bearer("token"))
25-
_ = err
23+
res, _ = httpx.Get[map[string]any](c, "https://httpbin.org/headers", httpx.Bearer("token"))
2624
httpx.Dump(res) // dumps map[string]any
2725
// #map[string]interface {} {
2826
// headers => #map[string]interface {} {

examples/before/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ func main() {
1313

1414
// Example: mutate req.Request
1515
c := httpx.New()
16-
res, err := httpx.Get[map[string]any](c, "https://httpbin.org/get", httpx.Before(func(r *req.Request) {
16+
res, _ := httpx.Get[map[string]any](c, "https://httpbin.org/get", httpx.Before(func(r *req.Request) {
1717
r.EnableDump()
1818
}))
19-
_ = err
2019
httpx.Dump(res) // dumps map[string]any
2120
// #map[string]interface {} {
2221
// url => "https://httpbin.org/get" #string

examples/body/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ func main() {
1414
}
1515

1616
c := httpx.New()
17-
res, err := httpx.Post[any, map[string]any](c, "https://httpbin.org/post", nil, httpx.Body(Payload{Name: "Ana"}))
18-
_ = err
17+
res, _ := httpx.Post[any, map[string]any](c, "https://httpbin.org/post", nil, httpx.Body(Payload{Name: "Ana"}))
1918
httpx.Dump(res) // dumps map[string]any
2019
// #map[string]interface {} {
2120
// json => #map[string]interface {} {

0 commit comments

Comments
 (0)