Skip to content

Commit

Permalink
Merge pull request #43 from lestrrat-go/update-example
Browse files Browse the repository at this point in the history
Update example
  • Loading branch information
lestrrat authored Oct 8, 2024
2 parents 1f3f8d3 + 7171d7f commit 777755c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func ExampleClient() {
}))

options := []httprc.NewClientOption{
// By default the client will allow all URLs (which is what the option
// below is explicitly specifying). If you want to restrict what URLs
// are allowed, you can specify another whitelist.
//
// httprc.WithWhitelist(httprc.NewInsecureWhitelist()),
}
// If you would like to handle errors from asynchronous workers, you can specify a error sink.
Expand Down Expand Up @@ -52,6 +56,14 @@ func ExampleClient() {
defer ctrl.Shutdown(time.Second)

// Create a new resource that is synchronized every so often
//
// By default the client will attempt to fetch the resource once
// as soon as it can, and then if no other metadata is provided,
// it will fetch the resource every 15 minutes.
//
// If the resource responds with a Cache-Control/Expires header,
// the client will attempt to respect that, and will try to fetch
// the resource again based on the values obatained from the headers.
r, err := httprc.NewResource[HelloWorld](srv.URL, httprc.JSONTransformer[HelloWorld]())
if err != nil {
fmt.Println(err.Error())
Expand Down

0 comments on commit 777755c

Please sign in to comment.