httpsession

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultSession

type DefaultSession struct {
	// contains filtered or unexported fields
}

func NewDefaultSession added in v1.6.2

func NewDefaultSession(sessionProvider SessionProvider) *DefaultSession

func (*DefaultSession) Clear

func (d *DefaultSession) Clear() Session

func (*DefaultSession) Created added in v1.6.2

func (d *DefaultSession) Created() time.Time

func (*DefaultSession) Data

func (d *DefaultSession) Data() map[string]string

func (*DefaultSession) Delete

func (d *DefaultSession) Delete(key string)

func (*DefaultSession) Expire

func (d *DefaultSession) Expire() time.Time

func (*DefaultSession) GetInt64

func (d *DefaultSession) GetInt64(key string) int64

func (*DefaultSession) GetString

func (d *DefaultSession) GetString(key string) string

func (*DefaultSession) GetStruct

func (d *DefaultSession) GetStruct(key string, obj any)

func (*DefaultSession) Id added in v1.6.2

func (d *DefaultSession) Id() string

func (*DefaultSession) IsExpire

func (d *DefaultSession) IsExpire() bool

func (*DefaultSession) MarshalJSON added in v1.6.2

func (d *DefaultSession) MarshalJSON() ([]byte, error)

func (*DefaultSession) PutInt64

func (d *DefaultSession) PutInt64(key string, value int64) Session

func (*DefaultSession) PutString

func (d *DefaultSession) PutString(key string, value string) Session

func (*DefaultSession) PutStruct

func (d *DefaultSession) PutStruct(key string, value any) Session

func (*DefaultSession) Reload

func (d *DefaultSession) Reload() Session

func (*DefaultSession) Save

func (d *DefaultSession) Save() error

func (*DefaultSession) SetExpire

func (d *DefaultSession) SetExpire(expire time.Time) Session

func (*DefaultSession) UnmarshalJSON added in v1.6.2

func (d *DefaultSession) UnmarshalJSON(data []byte) error

func (*DefaultSession) Updated added in v1.6.2

func (d *DefaultSession) Updated() time.Time

type MockSession added in v1.9.0

type MockSession struct {
	mock.Mock
}

MockSession is a mock implementation of Session interface It provides complete testify/mock integration for testing session behaviors

func NewMockSession added in v1.9.0

func NewMockSession() *MockSession

NewMockSession creates a new MockSession instance

func (*MockSession) Clear added in v1.9.0

func (m *MockSession) Clear() Session

Clear removes all data from the session

func (*MockSession) Created added in v1.9.0

func (m *MockSession) Created() time.Time

Created returns the session creation time

func (*MockSession) Data added in v1.9.0

func (m *MockSession) Data() map[string]string

Data returns all session data

func (*MockSession) Delete added in v1.9.0

func (m *MockSession) Delete(key string)

Delete removes a specific key from the session

func (*MockSession) Expire added in v1.9.0

func (m *MockSession) Expire() time.Time

Expire returns the session expiration time

func (*MockSession) GetInt64 added in v1.9.0

func (m *MockSession) GetInt64(key string) int64

GetInt64 gets an int64 value by key

func (*MockSession) GetString added in v1.9.0

func (m *MockSession) GetString(key string) string

GetString gets a string value by key

func (*MockSession) GetStruct added in v1.9.0

func (m *MockSession) GetStruct(key string, obj any)

GetStruct gets a struct value by key and unmarshals into obj

func (*MockSession) Id added in v1.9.0

func (m *MockSession) Id() string

Id returns the session ID

func (*MockSession) IsExpire added in v1.9.0

func (m *MockSession) IsExpire() bool

IsExpire checks if the session has expired

func (*MockSession) PutInt64 added in v1.9.0

func (m *MockSession) PutInt64(key string, value int64) Session

PutInt64 stores an int64 value by key

func (*MockSession) PutString added in v1.9.0

func (m *MockSession) PutString(key string, value string) Session

PutString stores a string value by key

func (*MockSession) PutStruct added in v1.9.0

func (m *MockSession) PutStruct(key string, value any) Session

PutStruct stores a struct value by key (marshals to JSON)

func (*MockSession) Reload added in v1.9.0

func (m *MockSession) Reload() Session

Reload reloads the session from storage

func (*MockSession) Save added in v1.9.0

func (m *MockSession) Save() error

Save persists the session

func (*MockSession) SetExpire added in v1.9.0

func (m *MockSession) SetExpire(expire time.Time) Session

SetExpire sets the session expiration time

func (*MockSession) Updated added in v1.9.0

func (m *MockSession) Updated() time.Time

Updated returns the session last update time

type MockSessionProvider added in v1.9.0

type MockSessionProvider struct {
	mock.Mock
}

MockSessionProvider is a mock implementation of SessionProvider interface It provides complete testify/mock integration for testing session provider behaviors

func NewMockSessionProvider added in v1.9.0

func NewMockSessionProvider() *MockSessionProvider

NewMockSessionProvider creates a new MockSessionProvider instance

func (*MockSessionProvider) Delete added in v1.9.0

func (m *MockSessionProvider) Delete(key string)

Delete removes a session by key

func (*MockSessionProvider) NewSession added in v1.9.0

func (m *MockSessionProvider) NewSession(expire time.Time) Session

NewSession creates a new session with expiration time

func (*MockSessionProvider) Save added in v1.9.0

func (m *MockSessionProvider) Save(session Session) error

Save saves a session

func (*MockSessionProvider) Session added in v1.9.0

func (m *MockSessionProvider) Session(key string) Session

Session returns a specific session by key

func (*MockSessionProvider) Sessions added in v1.9.0

func (m *MockSessionProvider) Sessions() map[string]Session

Sessions returns all sessions (readonly)

func (*MockSessionProvider) SetSaveError added in v1.9.0

func (m *MockSessionProvider) SetSaveError(err error)

SetSaveError sets up the mock to return an error on Save calls (for testing error scenarios)

func (*MockSessionProvider) Type added in v1.9.0

func (m *MockSessionProvider) Type() SessionType

Type returns the session provider type

type Session

type Session interface {
	Id() string
	GetString(key string) string
	PutString(key string, value string) Session
	GetInt64(key string) int64
	PutInt64(key string, value int64) Session
	GetStruct(key string, obj any)
	PutStruct(key string, value any) Session
	Clear() Session
	Delete(key string)
	Created() time.Time
	Updated() time.Time
	Expire() time.Time
	Save() error
	Reload() Session
	Data() map[string]string
	SetExpire(expire time.Time) Session
	IsExpire() bool
}

type SessionProvider

type SessionProvider interface {
	Type() SessionType
	NewSession(expire time.Time) Session
	// Sessions Readonly
	Sessions() map[string]Session
	Session(key string) Session
	Save(session Session) error
	Delete(key string)
}

type SessionType added in v1.6.3

type SessionType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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