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

epformpage

package
v1.152.2 Latest Latest
Warning

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

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

Documentation

Overview

Package epformpage is the page the platform renders a form on (#2177, #2331): GET /forms/{endpoint}, a document of its own that fetches the spec the form's endpoint answers, renders its fields, answers the endpoint's bot check and posts the submission back, showing the field errors, the confirmation or following the redirect. An HTML or JSX asset embeds a form by declaring mcp:form:<endpoint>, which the asset is served with rewritten to this page's address, in a frame of its own inside the asset's; a site the platform does not host frames the same address, with the snippet the form's page in the portal offers.

A site may frame the page only when the binding's allowed_origins list it (frame-ancestors). An asset frames it from inside a sandbox whose opaque origin no source expression names, so the asset's rewrite hands the page an embed marker (epform.EmbedParam), and a page opened with a valid one sends no frame-ancestors.

The form's endpoint is called with no cookie. Who a signed-in person is reaches an authenticated form as a viewer token (epform.ViewerParam): the one an asset's rewrite wrote into the address, or, for a page opened directly, one the page signs from the browser's session. With neither, an authenticated form's page sends a browser opening it to sign in, and asks one that frames it to.

Index

Constants

View Source
const (
	// PathPrefix is the form pages' prefix; a form's page is
	// PathPrefix + its endpoint's name. It is epform.PagePrefix written out,
	// because the route gates read a pattern from this package's constants.
	PathPrefix = "/forms/"
	// ScriptPath serves the page's script. An endpoint name never starts
	// with "_", so it is never a form's page.
	ScriptPath = PathPrefix + "_/form.js"

	// ThemeParam picks the page's theme ("light" or "dark") over the
	// viewer's preference; the page does not pass it to the form.
	ThemeParam = "form_theme"
	// HeightMessage is the type of the message the page posts its parent
	// with its height, which the embed snippet sizes its frame by.
	HeightMessage = "mcp-form:height"
)

The routes.

Variables

This section is empty.

Functions

func LoginURL

func LoginURL(returnTo string) string

LoginURL is the deployment's browser sign-in returning to returnTo.

Types

type Handler

type Handler struct {
	Runner Resolver
	// BaseURL is the deployment's public address; empty takes the request's
	// origin (assetrefs.BaseURL).
	BaseURL string
	// ViewerKey signs and opens viewer tokens and, derived from it, embed
	// markers (epform.ViewerKey); nil honors no marker and signs no viewer.
	ViewerKey []byte
	// Session is the signed-in person the request's session or key names,
	// nil for none (endpointwire.Authenticator).
	Session func(r *http.Request) (*eprun.Caller, error)
	// SignIn is where a browser signs in and comes back to returnTo; nil
	// when the deployment has no browser sign-in.
	SignIn func(returnTo string) string
}

Handler serves the form pages.

func (*Handler) Mount

func (h *Handler) Mount(mux *http.ServeMux)

Mount registers the routes on mux.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, name string) (*eprun.Target, error)
}

Resolver is the endpoint runner, which says what a name serves.

Jump to

Keyboard shortcuts

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