versionhttp

package
v1.108.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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 New

func New(deps Deps) *Handler

New builds the handler.

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

func (h *Handler) RegisterPortal(mux *http.ServeMux, wrap func(http.Handler) http.Handler)

RegisterPortal mounts the portal version routes, wrapped in the portal auth middleware.

type PortalIdentity

type PortalIdentity struct {
	Email   string
	Persona string
	IsAdmin bool
}

PortalIdentity is the portal caller resolved by the injected accessor.

type Registrar

type Registrar interface {
	RegisterRuntimePrompt(p *prompt.Prompt)
	UnregisterRuntimePrompt(name string)
}

Registrar refreshes a prompt's name-keyed runtime metadata after an approved version changes the live row. The prompt layer satisfies it.

Jump to

Keyboard shortcuts

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