From 70d876ed82fd9f6d50e6ec4a73a4320370318841 Mon Sep 17 00:00:00 2001 From: George Psarakis Date: Fri, 8 Dec 2023 11:57:20 +0200 Subject: [PATCH] chore: Update README to include Client constructor options Closes #194 --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 5b5e3010..fc557a8f 100644 --- a/README.md +++ b/README.md @@ -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.