engine

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicatedName = errors.New("duplicated form name")

Functions

func New

func New(cfg Config, options ...FormOption) (http.Handler, error)

func NewForm

func NewForm(config FormConfig, options ...FormOption) http.HandlerFunc

Types

type AMQPFactory added in v0.3.0

type AMQPFactory interface {
	Create(definition schema.AMQP) notifications.Notification
}

type Config

type Config struct {
	Forms           []schema.Form
	Storage         Storage
	WebhooksFactory WebhooksFactory
	AMQPFactory     AMQPFactory
	Listing         bool
	Captcha         []web.Captcha
}

type FormConfig

type FormConfig struct {
	Definition      schema.Form        // schema definition
	ViewForm        *template.Template // template to show main form
	ViewSuccess     *template.Template // template to show result (success) after submit
	ViewFail        *template.Template // template to show result (fail) after submit
	ViewCode        *template.Template // template to show code access
	ViewForbidden   *template.Template // template to show access denied
	Storage         Storage            // where to store data
	WebhooksFactory WebhooksFactory
	AMQPFactory     AMQPFactory
	XSRF            bool // check XSRF token. Disable if form is exposed as API.
	Captcha         []web.Captcha
}

type FormOption

type FormOption func(config *FormConfig)

func WithXSRF

func WithXSRF(enable bool) FormOption

type Storage

type Storage interface {
	Store(ctx context.Context, table string, fields map[string]any) (map[string]any, error)
}

type WebhooksFactory added in v0.3.0

type WebhooksFactory interface {
	Create(webhook schema.Webhook) notifications.Notification
}

Jump to

Keyboard shortcuts

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