sessions

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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