Skip to content

Commit

Permalink
chore: Update README to include Client constructor options
Browse files Browse the repository at this point in the history
Closes #194
  • Loading branch information
georgepsarakis committed Dec 11, 2023
1 parent d95ad77 commit 1dc9d2a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ follow the same structure that can be found in the [Backend API documentation](h

For more examples on how to use the client, refer to the [examples](https://github.com/clerkinc/clerk-sdk-go/tree/main/examples/operations)

### Options

The SDK `Client` constructor can also accept additional options defined [here](https://github.com/clerk/clerk-sdk-go/blob/main/clerk/clerk_options.go).

A common use case is injecting your own [`http.Client` object](https://pkg.go.dev/net/http#Client) for testing or automatically retrying requests.
An example using [go-retryablehttp](https://github.com/hashicorp/go-retryablehttp/#getting-a-stdlib-httpclient-with-retries) is shown below:

```go
retryClient := retryablehttp.NewClient()
retryClient.RetryMax = 5
standardClient := retryClient.StandardClient() // *http.Client

clerkSDKClient := clerk.NewClient(token, clerk.WithHTTPClient(standardClient))
```

## Middleware

The SDK provides the [`WithSessionV2`](https://pkg.go.dev/github.com/clerkinc/clerk-sdk-go/v2/clerk#WithSessionV2) middleware that injects the active session into the request's context.
Expand Down

0 comments on commit 1dc9d2a

Please sign in to comment.