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

eventshttp

package
v1.152.1 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: 13 Imported by: 0

Documentation

Overview

Package eventshttp serves the webhook source a managed script runs for (#2332): each event the source stores enqueues one run of the script, with trigger event, carrying the event as run.event. The owner and an administrator set it, as they set a schedule; anyone else is refused by the edit funnel. Naming a source is reading it, so only an administrator may name any source, and anyone else the source of a form they own.

The composition root mounts it beside scripthttp (ForPortal), whose edit funnel and owner check it uses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Check is sourcerule.Rule.Check.
	Check func(ctx context.Context, source, callerEmail string, admin bool) error
	// Summary is how the script's event runs stand (scriptevents.PostgresStore).
	Summary func(ctx context.Context, scriptID string, since time.Time) (scriptevents.EventSummary, error)
	// MaxQueued is scripts.events.max_queued; zero is the default.
	MaxQueued int
}

Config is the rule a named source is held to and the store event runs are read from.

func ConfigFor

func ConfigFor(db *sql.DB, enc whsource.Encryptor, maxQueued int) Config

ConfigFor is the Config over the platform's database: the stored webhook sources, the scripts a form source's owner is read from, and the event runs.

type Deps

type Deps struct {
	// Config is the source rule and the event run store.
	Config Config
	// Edit applies mutate to the script in the path for a caller who owns
	// it, through the edit funnel, writing any refusal itself.
	Edit func(w http.ResponseWriter, r *http.Request, mutate func(*script.Script)) (*script.Script, bool)
	// Owned resolves the script in the path for its owner or an
	// administrator, writing any refusal itself.
	Owned func(w http.ResponseWriter, r *http.Request) (scriptID, actor string, ok bool)
	// Caller is the request's caller: email and whether an administrator.
	Caller func(r *http.Request) (email string, admin bool)
	// Now is the clock; nil is time.Now.
	Now func() time.Time
}

Deps carries what the routes need.

type Handler

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

Handler serves the routes.

func ForPortal

func ForPortal(scripts *scripthttp.Handler, deps scripthttp.Deps, cfg Config) *Handler

ForPortal is the handler over scripthttp's edit funnel and owner check and the caller deps.PortalUser resolves.

func New

func New(deps Deps) *Handler

New builds the handler.

func (*Handler) Register

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

Register mounts the routes, wrapped in the portal authentication middleware.

Jump to

Keyboard shortcuts

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