session

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2017 License: BSD-3-Clause Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSessionNotFound is error if session does not exist.
	ErrSessionNotFound = errors.New("session not found")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	Values *map[string]interface{} `json:"values,omitempty"`
	MaxAge *int                    `json:"max-age,omitempty"`
}

Options is a structure with parameters as pointers to set session data. If a parameter is nil, the corresponding Session parameter will not be changed.

type Service

type Service interface {
	// Session retrieves a Session instance.
	Session(id string) (*Session, error)
	// CreateSession creates a new Session instance.
	CreateSession(*Options) (*Session, error)
	// UpdateSession changes data of an existing Session.
	UpdateSession(id string, o *Options) (*Session, error)
	// DeleteSession deletes an existing Session.
	DeleteSession(id string) error
}

Service defines functions that Session provider must have.

type Session

type Session struct {
	// A unique Session ID.
	ID string `json:"id"`
	// A mapping of named arbitrary data that Session holds.
	Values map[string]interface{} `json:"values,omitempty"`
	// MaxAge is an integer that represents duration in seconds and
	// can be used in setting expiration of a HTTP cookie.
	MaxAge int `json:"max-age,omitempty"`
}

Session holds session ID and values associated.

Directories

Path Synopsis
Package boltSession provides a Service that is using local BoltDB database to store Session data.
Package boltSession provides a Service that is using local BoltDB database to store Session data.
Package httpSession provides a HTTP client to an external session service that can respond to HTTP requests defined here.
Package httpSession provides a HTTP client to an external session service that can respond to HTTP requests defined here.

Jump to

Keyboard shortcuts

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