Documentation
¶
Overview ¶
Package adminhttp exposes a mountable, auth-agnostic JSON CRUD handler for managing flagpole feature definitions. Wrap it with your own auth middleware.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler returns an http.Handler serving:
GET /flags -> {key: Record} (active)
GET /flags?archived=true -> {key: Record} (archived)
PUT /flags/{key} -> upsert (body = Record JSON; archived ignored)
DELETE /flags/{key} -> archive
POST /flags/{key}/restore -> restore an archived flag
Types ¶
type Record ¶ added in v0.4.0
type Record struct {
flagpole.Feature
Description string `json:"description,omitempty"`
Archived bool `json:"archived,omitempty"`
}
Record is a feature definition plus its admin metadata. The embedded Feature keeps the JSON a superset of a bare Feature — defaultValue/rules sit at the top level alongside description/archived — so consumers that only read the evaluation shape keep working unchanged.
type Store ¶
type Store interface {
List(ctx context.Context) (map[string]Record, error)
ListArchived(ctx context.Context) (map[string]Record, error)
Upsert(ctx context.Context, key string, r Record) error
Archive(ctx context.Context, key string) error
Restore(ctx context.Context, key string) error
}
Store is the persistence the admin handler operates on. A Postgres-backed implementation typically lives next to your sourcepg setup.
Archive and Restore should be idempotent: implementations should return nil even when the key does not exist (the handler responds 200 either way).