Skip to content

Commit

Permalink
fix: default url not picked up
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Demaria <[email protected]>
  • Loading branch information
fabriziodemaria committed Sep 9, 2024
1 parent 36d2627 commit 1af316b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ require (
Below is an example for how to create a OpenFeature client using the Confidence flag provider, and then resolve
a flag with a boolean attribute.

The provider is configured via `APIConfig`, with which you can set the api key for authentication.
Optionally, a custom resolve API url can be configured if, for example, the resolver service is running on
a locally deployed side-car.
The provider is configured via `NewAPIConfig(...)`, with which you can set the api key for authentication.
Optionally, a custom resolve API url can be configured if, for example, the resolver service is running on a locally deployed side-car (`NewAPIConfigWithUrl(...)`).

The flag will be applied immediately, meaning that Confidence will count the targeted user as having received the treatment.

Expand Down
3 changes: 1 addition & 2 deletions demo/GoDemoApp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func main() {
fmt.Println("Fetching the flags...")

confidence := c.NewConfidenceBuilder().SetAPIConfig(c.APIConfig{APIKey: "API_KEY"}).Build()
confidence := c.NewConfidenceBuilder().SetAPIConfig(*c.NewAPIConfig("API_KEY")).Build()
targetingKey := "Random_targeting_key"
confidence.PutContext("targeting_key", targetingKey)

Expand All @@ -34,5 +34,4 @@ func main() {
wg := confidence.Track(context.Background(), "page-viewed", map[string]interface{}{})
wg.Wait()
fmt.Println("Event sent")

}
2 changes: 1 addition & 1 deletion pkg/confidence/http_resolve_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (client HttpResolveClient) SendResolveRequest(ctx context.Context,

payload := bytes.NewBuffer(jsonRequest)
req, err := http.NewRequestWithContext(ctx,
http.MethodPost, fmt.Sprintf("%s/flags:resolve", client.Config.APIResolveUrl), payload)
http.MethodPost, fmt.Sprintf("%s/v1/flags:resolve", client.Config.APIResolveUrl), payload)
if err != nil {
return ResolveResponse{}, err
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/confidence/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ type APIConfig struct {
func NewAPIConfig(apiKey string) *APIConfig {
return &APIConfig{
APIKey: apiKey,
APIResolveUrl: "https://resolver.confidence.dev/v1",
APIResolveUrl: "https://resolver.confidence.dev",
}
}

func NewAPIConfigWithUrl(apiKey, apiResolveUrl string) *APIConfig {
return &APIConfig{
APIKey: apiKey,
APIResolveUrl: apiResolveUrl,
}
}

Expand Down

0 comments on commit 1af316b

Please sign in to comment.