mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 23:57:50 -05:00
feat(BRIDGE-278): additional query parameter for feature flag route corresponding to stickiness constraint
This commit is contained in:
committed by
Atanas Janeshliev
parent
e6d3af81df
commit
bf97394725
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func (c *Client) GetFeatures(ctx context.Context) (FeatureFlagResult, error) {
|
||||
func (c *Client) GetFeatures(ctx context.Context, stickyKey uuid.UUID) (FeatureFlagResult, error) {
|
||||
res := FeatureFlagResult{}
|
||||
|
||||
if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
|
||||
return r.SetResult(&res).Get("/feature/v2/frontend")
|
||||
return r.SetResult(&res).Get(getFeatureFlagEndpoint(stickyKey))
|
||||
}); err != nil {
|
||||
return FeatureFlagResult{}, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package proton
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type FeatureFlagResult struct {
|
||||
@@ -14,10 +18,17 @@ type FeatureToggle struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func (m *Manager) GetFeatures(ctx context.Context) (FeatureFlagResult, error) {
|
||||
func getFeatureFlagEndpoint(stickyKey uuid.UUID) string {
|
||||
params := url.Values{}
|
||||
params.Set("bridgeStickyKey", stickyKey.String())
|
||||
path := fmt.Sprintf("/feature/v2/frontend?%s", params.Encode())
|
||||
return path
|
||||
}
|
||||
|
||||
func (m *Manager) GetFeatures(ctx context.Context, stickyKey uuid.UUID) (FeatureFlagResult, error) {
|
||||
responseData := FeatureFlagResult{}
|
||||
|
||||
_, err := m.r(ctx).SetResult(&responseData).Get("/feature/v2/frontend")
|
||||
_, err := m.r(ctx).SetResult(&responseData).Get(getFeatureFlagEndpoint(stickyKey))
|
||||
if err != nil {
|
||||
return FeatureFlagResult{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user