Skip to content

Commit 61f10a1

Browse files
authored
Merge pull request #10 from mutablelogic/v1
Updated README
2 parents c5a9eb5 + af35c2b commit 61f10a1

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ This repository contains a generic HTTP client which can be adapted to provide:
88
* Ability to send data of type `application/x-www-form-urlencoded`
99
* Debugging capabilities to see the request and response data
1010

11+
Documentation: https://pkg.go.dev/github.com/mutablelogic/go-client/pkg/client
12+
13+
There are also some example API clients:
14+
15+
* [Bitwarden Client](https://github.com/mutablelogic/go-client/tree/main/pkg/bitwarden)
16+
* [Elevenlabs Client](https://github.com/mutablelogic/go-client/tree/main/pkg/elevenlabs)
17+
* [Home Assistant Client](https://github.com/mutablelogic/go-client/tree/main/pkg/homeassistant)
18+
* [IPify Client](https://github.com/mutablelogic/go-client/tree/main/pkg/ipify)
19+
* [Mistral API Client](https://github.com/mutablelogic/go-client/tree/main/pkg/mistral)
20+
* [NewsAPI client](https://github.com/mutablelogic/go-client/tree/main/pkg/newsapi)
21+
* [OpenAI client](https://github.com/mutablelogic/go-client/tree/main/pkg/openai)
22+
1123
## Basic Usage
1224

1325
The following example shows how to decode a response from a GET request
@@ -40,7 +52,7 @@ func main() {
4052
Various options can be passed to the client `New` method to control its behaviour:
4153

4254
* `OptEndpoint(value string)` sets the endpoint for all requests
43-
* `OptTimeout(value time.Duration)` sets the timeout on any request, which defaults to 10 seconds
55+
* `OptTimeout(value time.Duration)` sets the timeout on any request, which defaults to 30 seconds
4456
* `OptUserAgent(value string)` sets the user agent string on each API request
4557
* `OptTrace(w io.Writer, verbose bool)` allows you to debug the request and response data.
4658
When `verbose` is set to true, it also displays the payloads
@@ -112,7 +124,7 @@ type Payload interface {
112124
}
113125
```
114126

115-
### Request options
127+
## Request options
116128

117129
The signature of the `Do` method is:
118130

@@ -135,7 +147,7 @@ Various options can be passed to modify each individual request when using the `
135147
* `OptHeader(key, value string)` appends a custom header to the request
136148

137149

138-
### Authentication
150+
## Authentication
139151

140152
The authentication token can be set as follows:
141153

@@ -159,3 +171,14 @@ func main() {
159171
// ...
160172
}
161173
```
174+
175+
You can also set the token on a per-request basis using the `OptToken` option in call to the `Do` method.
176+
177+
## Form submission
178+
179+
You can create a payload with form data:
180+
181+
* `client.NewFormRequest(payload any, accept string)` returns a new request with a Form data payload which defaults to POST.
182+
* `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.
183+
184+
The payload should be a `struct` where the fields are converted to form tuples. File uploads require a field of type `multipart.File`.

0 commit comments

Comments
 (0)