session

package
v0.0.0-...-a8d7ca2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *Options)

Option defines a single option function.

func WithLifetime

func WithLifetime(v time.Duration) Option

WithLifetime provides a function to set the lifetime option.

func WithName

func WithName(v string) Option

WithName provides a function to set the secure option.

func WithPath

func WithPath(v string) Option

WithPath provides a function to set the path option.

func WithSecure

func WithSecure(v bool) Option

WithSecure provides a function to set the secure option.

func WithStore

func WithStore(v scs.Store) Option

WithStore provides a function to set the store option.

type Options

type Options struct {
	Store    scs.Store
	Lifetime time.Duration
	Name     string
	Path     string
	Secure   bool
}

Options defines the available options for this package.

type Session

type Session struct {
	Manager *scs.SessionManager
}

Session is a simple wrapper around a session manager.

func New

func New(opts ...Option) *Session

New simply initializes a new session storage used for OAuth2/OIDC.

func (*Session) Destroy

func (s *Session) Destroy(ctx context.Context) error

Destroy simply wipes the whole session, used for logout.

func (*Session) Get

func (s *Session) Get(ctx context.Context, key string) string

Get simply gets a value from the session cookie.

func (*Session) Middleware

func (s *Session) Middleware(next http.Handler) http.Handler

Middleware defines the middleware to store sessions.

func (*Session) Pop

func (s *Session) Pop(ctx context.Context, key string) string

Pop simply pops a value from the session cookie.

func (*Session) Put

func (s *Session) Put(ctx context.Context, key, val string)

Put simply puts a value into the session cookie.

func (*Session) User

func (s *Session) User(key string) (string, error)

User simply gets the current user ID from the session.

Jump to

Keyboard shortcuts

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