@@ -14,7 +14,7 @@ It keeps req's power and escape hatches, while making the 90% use case feel effo
1414 <a href="https://goreportcard.com/report/github.com/goforj/httpx"><img src="https://goreportcard.com/badge/github.com/goforj/httpx" alt="Go Report Card"></a>
1515 <a href="https://codecov.io/gh/goforj/httpx" ><img src="https://codecov.io/gh/goforj/httpx/graph/badge.svg?token=R5O7LYAD4B"/></a>
1616<!-- test-count:embed:start -->
17- <img src="https://img.shields.io/badge/tests-135 -brightgreen" alt="Tests">
17+ <img src="https://img.shields.io/badge/tests-137 -brightgreen" alt="Tests">
1818<!-- test-count:embed:end -->
1919</p >
2020
@@ -121,13 +121,14 @@ They are compiled by `example_compile_test.go` to keep docs and code in sync.
121121| Group | Functions |
122122| ------:| -----------|
123123| ** Auth** | [ Auth] ( #auth ) [ Basic] ( #basic ) [ Bearer] ( #bearer ) |
124+ | ** Bind** | [ Bind] ( #bind ) [ Get] ( #get ) |
124125| ** Client** | [ Default] ( #default ) [ New] ( #new ) [ Raw] ( #raw ) [ Req] ( #req ) |
125126| ** Client Options** | [ WithBaseURL] ( #withbaseurl ) [ WithErrorMapper] ( #witherrormapper ) [ WithHeader] ( #withheader ) [ WithHeaders] ( #withheaders ) [ WithMiddleware] ( #withmiddleware ) [ WithTimeout] ( #withtimeout ) [ WithTransport] ( #withtransport ) |
126127| ** Debugging** | [ Dump] ( #dump ) [ DumpTo] ( #dumpto ) [ DumpToFile] ( #dumptofile ) [ WithDumpAll] ( #withdumpall ) [ WithDumpEachRequest] ( #withdumpeachrequest ) [ WithDumpEachRequestTo] ( #withdumpeachrequestto ) |
127128| ** Download Options** | [ OutputFile] ( #outputfile ) |
128129| ** Errors** | [ Error] ( #error ) |
129130| ** Request Options** | [ Before] ( #before ) [ Body] ( #body ) [ Form] ( #form ) [ Header] ( #header ) [ Headers] ( #headers ) [ JSON] ( #json ) [ Path] ( #path ) [ Paths] ( #paths ) [ Queries] ( #queries ) [ Query] ( #query ) [ Timeout] ( #timeout ) |
130- | ** Requests** | [ Delete] ( #delete ) [ Get ] ( #get ) [ Patch] ( #patch ) [ Post] ( #post ) [ Put] ( #put ) |
131+ | ** Requests** | [ Delete] ( #delete ) [ Patch] ( #patch ) [ Post] ( #post ) [ Put] ( #put ) |
131132| ** Requests (Context)** | [ DeleteCtx] ( #deletectx ) [ GetCtx] ( #getctx ) [ PatchCtx] ( #patchctx ) [ PostCtx] ( #postctx ) [ PutCtx] ( #putctx ) |
132133| ** Retry** | [ RetryBackoff] ( #retrybackoff ) [ RetryCondition] ( #retrycondition ) [ RetryCount] ( #retrycount ) [ RetryFixedInterval] ( #retryfixedinterval ) [ RetryHook] ( #retryhook ) [ RetryInterval] ( #retryinterval ) |
133134| ** Retry (Client)** | [ WithRetry] ( #withretry ) [ WithRetryBackoff] ( #withretrybackoff ) [ WithRetryCondition] ( #withretrycondition ) [ WithRetryCount] ( #withretrycount ) [ WithRetryFixedInterval] ( #withretryfixedinterval ) [ WithRetryHook] ( #withretryhook ) [ WithRetryInterval] ( #withretryinterval ) |
@@ -163,6 +164,42 @@ c := httpx.New()
163164_ = httpx.Get [string ](c, " https://example.com" , httpx.Bearer (" token" ))
164165```
165166
167+ ## Bind
168+
169+ ### <a id =" bind " ></a >Bind
170+
171+ Bind returns a typed wrapper around a client for fluent calls.
172+
173+ ``` go
174+ _ = httpx.Bind [string ](httpx.New ())
175+ ```
176+
177+ ### <a id =" get " ></a >Get
178+
179+ Get issues a GET request using the bound client.
180+
181+ _ Example: bound GET_
182+
183+ ``` go
184+ _ = httpx.Bind [string ](httpx.New ()).Get (" https://example.com" )
185+ ```
186+
187+ _ Example: fetch GitHub pull requests_
188+
189+ ``` go
190+ type PullRequest struct {
191+ Number int ` json:"number"`
192+ Title string ` json:"title"`
193+ }
194+
195+ c := httpx.New (httpx.WithHeader (" Accept" , " application/vnd.github+json" ))
196+ res := httpx.Get [[]PullRequest ](c, " https://api.github.com/repos/goforj/httpx/pulls" )
197+ if res.Err != nil {
198+ return
199+ }
200+ godump.Dump (res.Body )
201+ ```
202+
166203## Client
167204
168205### <a id =" default " ></a >Default
@@ -513,24 +550,6 @@ res := httpx.Delete[DeleteResponse](c, "https://api.example.com/users/1")
513550_, _ = res.Body , res.Err
514551```
515552
516- ### <a id =" get " ></a >Get
517-
518- Get issues a GET request using the provided client.
519-
520- ``` go
521- type PullRequest struct {
522- Number int ` json:"number"`
523- Title string ` json:"title"`
524- }
525-
526- c := httpx.New (httpx.WithHeader (" Accept" , " application/vnd.github+json" ))
527- res := httpx.Get [[]PullRequest ](c, " https://api.github.com/repos/goforj/httpx/pulls" )
528- if res.Err != nil {
529- return
530- }
531- godump.Dump (res.Body )
532- ```
533-
534553### <a id =" patch " ></a >Patch
535554
536555Patch issues a PATCH request using the provided client.
0 commit comments