Skip to main content

Custom filters

If you define custom feature filters on the server, you can register a matching evaluator in Go.

Register an evaluator​

type RegionFilter struct{}

func (RegionFilter) Evaluate(featureKey string, params map[string]any, ctx eval.Context) (bool, error) {
// Example: params["Region"] == "EU" etc.
region, _ := params["Region"].(string)
userRegion, _ := ctx.Traits["region"].(string)
return region != "" && userRegion == region, nil
}

client.RegisterFilter("Region", RegionFilter{})

Naming​

The evaluator name must match the filter name stored in definitions, for example:

  • Targeting
  • MyCompany.Region