Documentation
¶
Overview ¶
Package devactions exposes app-defined dev/staging actions (wipe, reseed, create account, ...) and test accounts to hamr over one token-gated endpoint. See docs/proposed-features/staging-proxy-and-dev-actions.md.
Index ¶
Constants ¶
const Prefix = "/_devactions"
Prefix is where the app mounts Handler.
Variables ¶
This section is empty.
Functions ¶
func SessionWhoAmI ¶
func SessionWhoAmI(sm *auth.SessionManager, lookup func(ctx context.Context, subjectID string) (*Account, error)) func(*http.Request) (*Account, error)
SessionWhoAmI builds a Registry.WhoAmI from a pkg/auth session manager: the session cookie is validated, then lookup turns the session's subject ID into the account shown in the widget (nil = not a known user).
Types ¶
type Account ¶
Account is a seeded test login offered by the widget. Phone is optional; when set, the widget links the user's texts in the SMS inbox.
type Action ¶
type Action struct {
Name string
Label string
Description string
Inputs []Input
Dangerous bool
Run func(ctx context.Context, in map[string]string) (message string, err error)
}
Action is one button in the hamr widget.
type Input ¶
type Input struct {
Name string
Label string
Type InputType
Options []string // InputSelect only
Default string
Required bool
}
Input describes one action parameter.
type InputType ¶
type InputType string
InputType is the kind of form field hamr renders for an Input.
type Registry ¶
type Registry struct {
Accounts func(ctx context.Context) ([]Account, error)
Disposable func(ctx context.Context) (bool, error)
// WhoAmI resolves the browser session on r (hamr forwards the browser's
// cookies) to the logged-in user, or nil when nobody is. Optional; it
// powers the widget's "<user>'s mail / texts" links. SessionWhoAmI builds
// one from a pkg/auth SessionManager. Password is never sent.
WhoAmI func(r *http.Request) (*Account, error)
// contains filtered or unexported fields
}
Registry holds the app's actions.
func (*Registry) Handler ¶
Handler returns the endpoint, or nil when the env gate fails: HAMR_ACTIONS_TOKEN must be set and HAMR_ACTIONS_ENV must be "development" or "staging". It panics if a Dangerous action exists without Disposable. The handler matches on the full request path, so mount it at the app root.