Skip to content

Commit 22221ac

Browse files
committed
Update xhttp README.md
1 parent 8cb993e commit 22221ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/xhttp/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ xhttp.DefaultOptions.DebugFunc = func(l *Log) {
4444
f := func(l *Log) {
4545
log.Println(l)
4646
}
47-
xhttp.NewRequest("POST", url, xhttp.WithDebugFunc(f))
47+
xhttp.Fetch(context.Background(), "POST", url, xhttp.WithDebugFunc(f))
4848
```
4949

5050
The log object contains the following fields
@@ -74,7 +74,7 @@ retryIf := func(resp *xhttp.Response, err error) error {
7474
}
7575
return nil
7676
}
77-
resp, err := xhttp.Fetch("GET", url, xhttp.WithRetry(retryIf, retry.Attempts(2)))
77+
resp, err := xhttp.Fetch(context.Background(), "GET", url, xhttp.WithRetry(retryIf, retry.Attempts(2)))
7878
```
7979

8080
Network error, no retry.
@@ -90,7 +90,7 @@ retryIf := func(resp *xhttp.Response, err error) error {
9090
}
9191
return nil
9292
}
93-
resp, err := xhttp.Fetch("GET", url, xhttp.WithRetry(retryIf, retry.Attempts(2)))
93+
resp, err := xhttp.Fetch(context.Background(), "GET", url, xhttp.WithRetry(retryIf, retry.Attempts(2)))
9494
```
9595

9696
## Middleware
@@ -112,7 +112,7 @@ logicMiddleware := func(next xhttp.HandlerFunc) xhttp.HandlerFunc {
112112
return resp, err
113113
}
114114
}
115-
resp, err := xhttp.Fetch("GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
115+
resp, err := xhttp.Fetch(context.Background(), "GET", "https://github.com/", xhttp.WithMiddleware(logicMiddleware))
116116
```
117117

118118
## Shutdown

0 commit comments

Comments
 (0)