Documentation ¶
Overview ¶
package whsess is a lightweight session storage mechanism for the webhelp package. Attempting to be a combination of minimal and useful. Implementing the Store interface is all one must do to provide a different session storage mechanism.
Index ¶
- Variables
- func HandlerWithStore(s Store, h http.Handler) http.Handler
- type CookieOptions
- type CookieStore
- func (cs *CookieStore) Clear(ctx context.Context, w http.ResponseWriter, namespace string) error
- func (cs *CookieStore) Load(ctx context.Context, r *http.Request, namespace string) (rv SessionData, err error)
- func (cs *CookieStore) Save(ctx context.Context, w http.ResponseWriter, namespace string, s SessionData) error
- type Session
- type SessionData
- type Store
Constants ¶
This section is empty.
Variables ¶
var (
SessionError = errors.NewClass("session")
)
Functions ¶
Types ¶
type CookieOptions ¶
type CookieStore ¶
type CookieStore struct { Options CookieOptions // contains filtered or unexported fields }
func NewCookieStore ¶
func NewCookieStore(secretKey []byte) *CookieStore
NewCookieStore creates a secure cookie store with default settings. Configure the Options field further if additional settings are required.
func NewLazyCookieStore ¶
func NewLazyCookieStore(secretKey func(context.Context) ([]byte, error)) ( cs *CookieStore)
NewLazyCookieStore is like NewCookieStore but loads the secretKey using the provided callback once. This is useful for delayed initialization after the first request for something like App Engine where you can't interact with a database without a context.
func (*CookieStore) Clear ¶
func (cs *CookieStore) Clear(ctx context.Context, w http.ResponseWriter, namespace string) error
Clear implements the Store interface. Not expected to be used directly.
func (*CookieStore) Load ¶
func (cs *CookieStore) Load(ctx context.Context, r *http.Request, namespace string) (rv SessionData, err error)
Load implements the Store interface. Not expected to be used directly.
func (*CookieStore) Save ¶
func (cs *CookieStore) Save(ctx context.Context, w http.ResponseWriter, namespace string, s SessionData) error
Save implements the Store interface. Not expected to be used directly.
type Session ¶
type Session struct { SessionData // contains filtered or unexported fields }
func Load ¶
Load will return the current session, creating one if necessary. This will fail if a store wasn't installed with HandlerWithStore somewhere up the call chain.
type SessionData ¶
type SessionData struct { New bool Values map[interface{}]interface{} }