feat(api): add feature flag management endpoints

Add FeatureHandler to manage lightweight runtime configuration toggles
stored in the Redis `meta:features` hash. This enables dynamic control
over system behavior (e.g., storage backends) via the admin API.

- Add `GET /admin/features` to list flags
- Add `PUT /admin/features` to update flags
- Update README with feature flag documentation
This commit is contained in:
zenfun
2025-12-15 15:01:01 +08:00
parent fb68e0f155
commit 11f6e81798
3 changed files with 121 additions and 0 deletions

View File

@@ -113,6 +113,7 @@ func main() {
handler := api.NewHandler(db, syncService, logWriter)
adminHandler := api.NewAdminHandler(masterService, syncService)
masterHandler := api.NewMasterHandler(masterService, syncService)
featureHandler := api.NewFeatureHandler(rdb)
// 4.1 Prime Redis snapshots so DP can start with data
if err := syncService.SyncAll(db); err != nil {
@@ -157,6 +158,8 @@ func main() {
adminGroup.Use(middleware.AdminAuthMiddleware(adminService))
{
adminGroup.POST("/masters", adminHandler.CreateMaster)
adminGroup.GET("/features", featureHandler.ListFeatures)
adminGroup.PUT("/features", featureHandler.UpdateFeatures)
// Other admin routes for managing providers, models, etc.
adminGroup.POST("/providers", handler.CreateProvider)
adminGroup.POST("/models", handler.CreateModel)