Help us shape the future of Go! Take the 2026 Go Developer Survey

flowhttp

package
v1.149.0 Latest Latest
Warning

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

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

Documentation

Overview

Package flowhttp serves a managed script version's flow graph (#1906): the diagram the script page's Flow tab draws, derived from the version's source by internal/platform/scriptflow.

It is REST only. The graph is for the people who own, review and depend on a script; an agent reads the code, so no MCP tool response carries it.

It is mounted by the composition root beside scripthttp, and reads a version through scripthttp's own lookup, so a version is found, and not found, the way every other script route finds it. The read rule is the source's: on the portal everyone signed in (#1866), on the admin surface the admin authentication middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditQuerier

type AuditQuerier interface {
	Query(ctx context.Context, filter audit.QueryFilter) ([]audit.Event, error)
}

AuditQuerier reads audit events; it is the read half of the audit store.

type Deps

type Deps struct {
	// Load resolves the script and version named by the path, or writes the
	// refusal and reports false (scripthttp.Handler.LoadScriptVersion).
	Load func(w http.ResponseWriter, r *http.Request) (*script.Script, *script.Version, bool)
	// SignedIn reports whether a portal request carries a user. The portal
	// route answers 401 without one.
	SignedIn func(r *http.Request) bool
	// Version reads another version of the same script, for ?compare=
	// (#1908) and for the version a run executed (#1907). Nil when the store
	// is absent; the comparison is then 404.
	Version func(ctx context.Context, scriptID string, version int) (*script.Version, error)
	// Run reads the run in the path for a signed-in caller entitled to it, or
	// writes the refusal (scripthttp.Handler.ReadableRun). Nil leaves the run
	// route unmounted.
	Run func(w http.ResponseWriter, r *http.Request) (*script.Run, bool)
	// Audit reads a run's audited calls. Nil draws a run with no calls.
	Audit AuditQuerier
	// ActsOn reports whether the caller owns the script or administers the
	// platform. Only they are shown the arguments a run's calls were sent: a
	// call made with the owner's roles may carry values only the owner should
	// read, and whoever requested a run is not its owner. Nil shows none.
	ActsOn func(r *http.Request, scriptID string) bool
	// Tiles reads a script's tile (#1909). Nil leaves the tile route
	// unmounted.
	Tiles TileReader
}

Deps carries the version lookup and, for the portal, who is signed in.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves the graph routes.

func ForAdmin

func ForAdmin(scripts *scripthttp.Handler, deps scripthttp.Deps) *Handler

ForAdmin builds the admin routes over the script routes' version lookup.

func ForPortal

func ForPortal(scripts *scripthttp.Handler, deps scripthttp.Deps, calls AuditQuerier, tiles TileReader) *Handler

ForPortal builds the portal routes over the script routes' own lookups, so a version and a run are found, and not found, the way every other script route finds them: the graph under the source's read rule (#1866), a run under the run's (the script's owner, an administrator, or whoever requested it). calls is where a run's calls are read from; nil draws a run with none. tiles serves a script's tile; nil leaves that route unmounted.

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 route under prefix, wrapped in the admin authentication middleware.

func (*Handler) RegisterPortal

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

RegisterPortal mounts the portal route, wrapped in the portal authentication middleware.

type TileReader

type TileReader interface {
	Tile(ctx context.Context, scriptID, variant string) (data []byte, current bool, err error)
}

TileReader reads one variant of a script's tile (#1909), or scripttiles.ErrNoTile, and whether it was drawn from the version the script is at.

Jump to

Keyboard shortcuts

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