adminhttp

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

func NewHandler(store Store) http.Handler

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL