You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -146,7 +146,9 @@ Various options can be passed to modify each individual request when using the `
146
146
*`OptToken(value Token)` adds an authorization header (overrides the client OptReqToken option)
147
147
*`OptQuery(value url.Values)` sets the query parameters to a request
148
148
*`OptHeader(key, value string)` appends a custom header to the request
149
-
149
+
*`OptResponse(func() error)` allows you to set a callback function to process a streaming response.
150
+
See below for more details.
151
+
*`OptNoTimeout()` disables the timeout on the request, which is useful for long running requests
150
152
151
153
## Authentication
152
154
@@ -183,3 +185,9 @@ You can create a payload with form data:
183
185
*`client.NewMultipartRequest(payload any, accept string)` returns a new request with a Multipart Form data payload which defaults to POST. This is useful for file uploads.
184
186
185
187
The payload should be a `struct` where the fields are converted to form tuples. File uploads require a field of type `multipart.File`.
188
+
189
+
## Streaming Responses
190
+
191
+
If the returned content is a stream of JSON responses, then you can use the `OptResponse(fn func() error)` option, which
192
+
will be called by the `Do` method for each response. The function should return an error if the stream should be terminated.
193
+
Usually, you would pair this option with `OptNoTimeout` to prevent the request from timing out.
0 commit comments