sessions

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidValue = errors.New("sessions: invalid value")
View Source
var ErrValidationErrorTypeAssertionFailed = errors.New("sessions: validation error type assertion failed")

Functions

This section is empty.

Types

type Store

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

Store implements formulate.ValidationStore using a combination of both HTTP session and filesystem. ValidationErrors are stored in the HTTP session, but the FormValue is stored in the os.TempDir() in a JSON encoded blob, with the filename formulate_val_* where * is replaced by a random string. The filesystem storage is used as the session storage is limited to 4096 bytes in most browsers.

func NewStore

func NewStore(r *http.Request, w http.ResponseWriter, store sessions.Store, sessionName string) *Store

NewStore creates a session store for saving validation. The sessionName provided must be unique to each form instance.

func (*Store) AddValidationError

func (s *Store) AddValidationError(field string, validationError formulate.ValidationError) error

func (*Store) ClearValidationErrors

func (s *Store) ClearValidationErrors() error

func (*Store) GetFormValue

func (s *Store) GetFormValue(out interface{}) (err error)

func (*Store) GetValidationErrors

func (s *Store) GetValidationErrors(field string) ([]formulate.ValidationError, error)

func (*Store) SetFormValue

func (s *Store) SetFormValue(i interface{}) error

Jump to

Keyboard shortcuts

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