configcattest

package
v7.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package configcattest provides an HTTP handler that can be used to test configcat scenarios in tests.

This API should be considered experimental for now and may change in a backwardly incompatible manner.

Package configcattest provides an HTTP handler that can be used to test configcat scenarios in tests.

Index

Constants

Variables

This section is empty.

Functions

func RandomSDKKey

func RandomSDKKey() string

RandomSDKKey returns a new randomly generated SDK key suitable for passing to SetFlags.

Types

type Flag

type Flag struct {
	// Default holds the default value for the flag.
	// It should hold one of the types string, float64, int or bool.
	Default interface{}

	// Rules holds a set of rules to check against in order.
	// If any rule is satisfied, its associated value is used,
	// otherwise the default value is used.
	Rules []Rule
}

Flag represents a configcat flag.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is an http.Handler that serves up configcat flags. The zero value is OK to use and has no flag configurations. Use SetFlags to add or update the set of flags served.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

func (*Handler) SetFlags

func (h *Handler) SetFlags(sdkKey string, flags map[string]*Flag) error

SetFlags sets or updates the flags served by the handler for the given SDK key. It can be called concurrently with other Handler methods.

Use RandomSDKKey to create a new SDK key.

type Operator

type Operator wireconfig.Operator

Operator defines a comparison operator.

func (Operator) String

func (op Operator) String() string

type Rule

type Rule struct {
	// ComparisonAttribute holds the user attribute to
	// check when evaluating the rule.
	ComparisonAttribute string

	// Comparator holds how the compare the above user
	// attribute to the comparison value.
	Comparator Operator

	// ComparisonValue holds the value to compare the
	// user attribute against.
	ComparisonValue string

	// Value holds the value for the flag if the rule is satisfied.
	// It should hold one of the types string, float64, int or bool
	// and be the same type as the default value of the
	// flag that it's associated with.
	Value interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL