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.
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.