Documentation
¶
Overview ¶
Package versionhttp exposes prompt version history, draft review actions, audit-derived usage stats (#1009), and prompt collection management (#1010) over REST. It serves both operator surfaces — the admin API (any prompt, approve/reject) and the portal API (visible prompts, read-only history plus usage for the caller's visible set, collection CRUD and assignment) — from one implementation. It lives beside pkg/prompt rather than inside pkg/admin or pkg/portal so those packages stay within the package-size budget; the composition root (internal/httpserver) mounts it under each surface's path prefix wrapped in that surface's own authentication middleware, and injects the identity accessors, so this package never imports either surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Store prompt.Store
Versions prompt.VersionStore
Usage prompt.UsageReader
Registrar Registrar
Collections prompt.CollectionStore
// AdminEmail returns the authenticated admin's email for approval stamps.
AdminEmail func(r *http.Request) string
// PortalUser resolves the authenticated portal caller, or nil when the
// request carries no user.
PortalUser func(r *http.Request) *PortalIdentity
// the caller, so their usage is as visible as the prompts themselves.
// Optional: nil when the deployment has no portal share store.
SharedPromptIDs func(ctx context.Context, userID, email string) ([]string, error)
}
Deps carries the collaborators the version handlers need. Store and Versions are required; Usage is optional (audit disabled leaves usage empty); Registrar is optional; Collections is optional (nil skips the collection routes). AdminEmail and PortalUser are the surface identity accessors injected by the composition root — each Register* call requires its accessor.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the prompt version and usage routes.
func (*Handler) RegisterAdmin ¶
func (h *Handler) RegisterAdmin(mux *http.ServeMux, prefix string, wrap func(http.Handler) http.Handler)
RegisterAdmin mounts the admin version routes under prefix (the admin API path prefix, e.g. /api/v1/admin), each wrapped in the admin auth middleware. The composition root registers these on the top-level mux, where their literal patterns take precedence over the admin subtree mount.
func (*Handler) RegisterPortal ¶
RegisterPortal mounts the portal version routes, wrapped in the portal auth middleware. Every portal handler goes through portalHandler, which resolves the caller identity and 401s unauthenticated requests in one place.
type PortalIdentity ¶
PortalIdentity is the portal caller resolved by the injected accessor.