Documentation ¶
Index ¶
- Variables
- type Config
- type Cookie
- func (c *Cookie) Delete(ctx *chain.Context, sid string)
- func (c *Cookie) Get(ctx *chain.Context, rawCookie string) (sid string, data map[string]any)
- func (c *Cookie) Init(config Config, router *chain.Router) (err error)
- func (c *Cookie) Name() string
- func (c *Cookie) Put(ctx *chain.Context, sid string, data map[string]any) (rawCookie string, err error)
- type Manager
- type Session
- func (s *Session) Clear()
- func (s *Session) Delete(key string)
- func (s *Session) Destroy()
- func (s *Session) Exist(key string) (exist bool)
- func (s *Session) Get(key string) any
- func (s *Session) GetMap() map[string]any
- func (s *Session) IgnoreChanges()
- func (s *Session) Put(key string, value any)
- func (s *Session) Renew()
- type Store
Constants ¶
This section is empty.
Variables ¶
var (
ErrCannotFetch = errors.New("cannot fetch session, check if there is a session.Manager configured")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Key string // session cookie key (required) Path string // see http.Cookie Domain string // see http.Cookie Expires time.Time // see http.Cookie RawExpires string // see http.Cookie MaxAge int // see http.Cookie Secure bool // see http.Cookie HttpOnly bool // see http.Cookie SameSite http.SameSite // see http.Cookie Raw string // see http.Cookie Unparsed []string // see http.Cookie }
Config cookie store expects conn.secret_key_base to be set
type Cookie ¶
type Cookie struct { Log string // Log level to use when the cookie cannot be decoded. Defaults to `debug`, can be set to false to disable it. Serializer chain.Serializer // cookie serializer module that defines `Encode(any)` and `Decode(any)`. Defaults to `json`. SigningKeyring *crypto.Keyring // a crypto.Keyring used with for signing/verifying a cookie. EncryptionKeyring *crypto.Keyring // a crypto.Keyring used for encrypting/decrypting a cookie. EncryptionAAD []byte // Additional authenticated data (AAD) }
Cookie Stores the session in a cookie. https://edgeapi.rubyonrails.org/classes/ActionDispatch/Session/CookieStore.html https://funcptr.net/2013/08/25/user-sessions,-what-data-should-be-stored-where-/
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func Fetch ¶
Fetch LazyLoad session from context. It only returns result if there is a global session.Manager configured
func FetchByKey ¶
FetchByKey LazyLoad session from context using a session.Manager Key
func (*Session) Clear ¶
func (s *Session) Clear()
Clear Clears the entire session.
This function removes every key from the session, clearing the session.
Note that, even if Clear is used, the session is still sent to the client. If the session should be effectively *dropped*, Destroy should be used.
func (*Session) Destroy ¶
func (s *Session) Destroy()
Destroy drops the session, a session cookie will not be included in the response
func (*Session) Get ¶
Get Returns session value for the given `key`. If `key` is not set, `nil` is returned.
func (*Session) IgnoreChanges ¶
func (s *Session) IgnoreChanges()
IgnoreChanges ignores all changes made to the session in this request cycle
type Store ¶
type Store interface { Name() string // Init Initializes the store. Init(config Config, router *chain.Router) error // Get Parses the given cookie. // // Returns a session id and the session contents. The session id is any value that can be used to identify the // session by the store. // // The session id may be nil in case the cookie does not identify any value in the store. The session contents must // be a map. Get(ctx *chain.Context, rawCookie string) (sid string, data map[string]any) // Put Stores the session associated with given session id. // // If an empty string is given as sid, a new session id should be generated and returned. Put(ctx *chain.Context, sid string, data map[string]any) (rawCookie string, err error) // Delete Removes the session associated with given session id from the store. Delete(ctx *chain.Context, sid string) }
Store Specification for session stores.