Documentation
¶
Overview ¶
Package versionhttp exposes prompt version history, draft review actions, and audit-derived usage stats over REST (#1009). It serves both operator surfaces — the admin API (any prompt, approve/reject) and the portal API (own prompts, read-only history plus usage for the caller's visible set) — 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
// 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
}
Deps carries the collaborators the version handlers need. Store and Versions are required; Usage is optional (audit disabled leaves usage empty); Registrar is optional. 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.
type PortalIdentity ¶
PortalIdentity is the portal caller resolved by the injected accessor.