Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFeatureNotAvailable = errors.New("this feature is not yet available for you") CanCreateCLIAPIKey = "can_create_cli_api_key" )
View Source
var Features = map[string]IsEnabledFunc{ CanCreateCLIAPIKey: func(r *http.Request) error { group := middleware.GetGroupFromContext(r.Context()) cfg, err := config.Get() if err != nil { return err } ff := newFliptClient(cfg) if ff == nil { return nil } var apiKey models.CreateAppApiKey body, err := io.ReadAll(r.Body) if err != nil { return err } r.Body = io.NopCloser(bytes.NewBuffer(body)) err = json.Unmarshal(body, &apiKey) if err != nil { return err } if apiKey.KeyType == datastore.CLIKey { isEnabled, err := ff.IsEnabled(CanCreateCLIAPIKey, map[string]string{ "group_id": group.UID, "organisation_id": group.OrganisationID, }) if err != nil { log.WithError(err).Error("failed to check flag on flipt") return err } if !isEnabled { return ErrFeatureNotAvailable } } return nil }, }
Functions ¶
func CanAccessFeature ¶
func CanAccessFeature(fn IsEnabledFunc) func(next http.Handler) http.Handler
Types ¶
type IsEnabledFunc ¶
Click to show internal directories.
Click to hide internal directories.