pageflow

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package pageflow contains experimental helpers for multi-step page flows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PageFlow

type PageFlow struct {
	Steps []Step
}

PageFlow contains the ordered steps for a flow.

func New

func New(steps []Step) *PageFlow

New creates a PageFlow from an ordered set of steps.

func (*PageFlow) AllPreviousValidated

func (f *PageFlow) AllPreviousValidated(session *SessionData) bool

AllPreviousValidated reports whether every step before the current one passed validation.

func (*PageFlow) CurrentStep

func (f *PageFlow) CurrentStep(session *SessionData) *Step

CurrentStep returns the active step for a session.

func (*PageFlow) FindStep

func (f *PageFlow) FindStep(name string) int

FindStep returns the index of a named step or -1 when absent.

func (*PageFlow) FirstStep

func (f *PageFlow) FirstStep() *Step

FirstStep returns the first configured step.

func (*PageFlow) Next

func (f *PageFlow) Next(session *SessionData) bool

Next moves a session to the next step.

func (*PageFlow) Prev

func (f *PageFlow) Prev(session *SessionData) bool

Prev moves a session to the previous step.

func (*PageFlow) SetCurrentStep

func (f *PageFlow) SetCurrentStep(session *SessionData, stepName string) bool

SetCurrentStep moves a session to a named step when it exists.

type SessionData

type SessionData struct {
	StepData  map[string]map[string]any
	Validated map[string]bool
	Current   string
}

SessionData stores per-session progress and data for a PageFlow.

SessionData is mutable session state. Do not share one SessionData value across goroutines without external synchronization.

func (*SessionData) GetAllData

func (session *SessionData) GetAllData() map[string]any

GetAllData returns all step data merged into one map.

func (*SessionData) GetStepData

func (session *SessionData) GetStepData(stepName string) map[string]any

GetStepData returns stored data for a step.

func (*SessionData) SetStepData

func (session *SessionData) SetStepData(stepName string, data map[string]any)

SetStepData stores data for a step.

func (*SessionData) SetStepValidated

func (session *SessionData) SetStepValidated(stepName string, valid bool)

SetStepValidated stores the validation state for a step.

type Step

type Step struct {
	Name     string
	Partial  *partial.Partial
	Validate func(r *http.Request, data map[string]any) error
}

Step describes a single page-flow step.

Jump to

Keyboard shortcuts

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