Feature rollout + experimentation package for Vapor.
FeaturesServer: evaluation, overrides (with audit history), middleware, and routes.FeaturesClient: lightweight API client for fetching and toggling features.FeaturesAdmin: scaffold target (not implemented yet).FeaturesShared: DTOs and shared feature key/value types.
FeaturesExampleServer uses Vapor + Fluent + SQLite and wires the package in configure.swift.
Run server:
swift run FeaturesExampleServer serve --hostname 127.0.0.1 --port 8080Seeded users:
11111111-1111-1111-1111-111111111111(free)22222222-2222-2222-2222-222222222222(pro)33333333-3333-3333-3333-333333333333(internal)
Call routes:
curl -s -H 'x-user-id: 11111111-1111-1111-1111-111111111111' http://127.0.0.1:8080/features
curl -s -H 'x-user-id: 11111111-1111-1111-1111-111111111111' -H 'content-type: application/json' -d '{"key":"new_checkout","enabled":true}' http://127.0.0.1:8080/features/toggle
curl -s -H 'x-user-id: 11111111-1111-1111-1111-111111111111' http://127.0.0.1:8080/gameInside your app configure.swift:
- Register your app DB.
- Build a
FeatureRegistrywithactive(ctx)closures. - Call
FeaturesServer.configure(on:config:registry:actorResolver:)with your app-defined context type. - Pass your auth middleware through
FeaturesConfiguration(authMiddleware:).
FeaturesServer.configure automatically registers the feature override migration.