Skip to content

Any OpenFeature provider (OFREP)

Evaluate flags with OpenFeature's OFREP providers in any language, or call the protocol directly.

Updated View as Markdown

https://flags.ezghcloud.com speaks the OpenFeature Remote Evaluation Protocol (OFREP), so OpenFeature’s own OFREP providers work with Feature Flags in every language OpenFeature supports, including mobile, Java and .NET. Configure them with:

  • Base URL: https://flags.ezghcloud.com
  • Header: Authorization: Bearer <SDK key>: a server key on servers, a client key in browsers and apps (SDK keys).

OFREP providers evaluate on EZGH’s servers, one request per evaluation or, for the web and mobile providers, one request for every flag. EZGH’s own server providers evaluate locally instead.

JavaScript

// Servers: npm install @openfeature/server-sdk @openfeature/ofrep-provider
import { OpenFeature } from "@openfeature/server-sdk"
import { OFREPProvider } from "@openfeature/ofrep-provider"

OpenFeature.setProvider(new OFREPProvider({
  baseUrl: "https://flags.ezghcloud.com",
  headers: [["Authorization", `Bearer ${process.env.EZGH_FLAGS_SDK_KEY}`]],
}))
// Browsers: npm install @openfeature/web-sdk @openfeature/ofrep-web-provider
import { OpenFeature } from "@openfeature/web-sdk"
import { OFREPWebProvider } from "@openfeature/ofrep-web-provider"

OpenFeature.setProvider(new OFREPWebProvider({
  baseUrl: "https://flags.ezghcloud.com",
  headers: [["Authorization", "Bearer ezgh_fc_…"]],
}))

Go

import "github.com/open-feature/go-sdk-contrib/providers/ofrep"

provider := ofrep.NewProvider("https://flags.ezghcloud.com", ofrep.WithBearerToken(os.Getenv("EZGH_FLAGS_SDK_KEY")))

Python

from openfeature.contrib.provider.ofrep import OFREPProvider

provider = OFREPProvider(
    "https://flags.ezghcloud.com",
    headers_factory=lambda: {"Authorization": f"Bearer {os.environ['EZGH_FLAGS_SDK_KEY']}"},
)

The protocol

Request Answers
POST /ofrep/v1/evaluate/flags/{key} One flag: { key, value, variant, reason, metadata }
POST /ofrep/v1/evaluate/flags Every flag the key sees, with an ETag; sending it back as If-None-Match answers 304 while nothing changed

The body is the evaluation context, at most 8 KB: { "context": { "targetingKey": "user-1842", "plan": "pro" } }.

curl -X POST https://flags.ezghcloud.com/ofrep/v1/evaluate/flags/new-checkout \
  -H "Authorization: Bearer $EZGH_FLAGS_SDK_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"targetingKey": "user-1842", "plan": "pro"}}'
{ "key": "new-checkout", "value": true, "variant": "true", "reason": "TARGETING_MATCH", "metadata": { "flagVersion": 12 } }
  • reason is DISABLED (the flag is off: the value is its off variation), TARGETING_MATCH, DEFAULT or STATIC (Targeting). metadata.flagVersion is the version of the flag’s targeting in that environment.
  • A flag that doesn’t exist, is archived, or isn’t client-side when the key is a client key answers 404 with errorCode FLAG_NOT_FOUND. A context that isn’t valid answers 400 with INVALID_CONTEXT.
  • A missing, unknown or revoked key answers 401. Over a rate limit answers 429 with Retry-After.
  • Browsers may call it from any site: it allows every origin, and sends no cookies.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close