Documentation
¶
Index ¶
- Variables
- type Cookie
- type PersistentJar
- func (pj *PersistentJar) Cleanup() (int64, error)
- func (pj *PersistentJar) Clear() error
- func (pj *PersistentJar) ClearDomain(domain string) error
- func (pj *PersistentJar) Cookies(u *url.URL) []*http.Cookie
- func (pj *PersistentJar) Count() (int64, error)
- func (pj *PersistentJar) ListAll() ([]*Cookie, error)
- func (pj *PersistentJar) SetCookies(u *url.URL, cookies []*http.Cookie)
- func (pj *PersistentJar) Store() Store
- type QueryOptions
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("cookie not found") ErrStoreClosed = errors.New("cookie store is closed") )
Common errors.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct {
ID string `json:"id"`
Domain string `json:"domain"`
Path string `json:"path"`
Name string `json:"name"`
Value string `json:"value"`
Secure bool `json:"secure"`
HttpOnly bool `json:"http_only"`
SameSite string `json:"same_site"`
Expires time.Time `json:"expires"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Cookie represents a stored cookie with all attributes.
func FromHTTPCookie ¶
FromHTTPCookie creates a Cookie from http.Cookie and URL.
func (*Cookie) ToHTTPCookie ¶
ToHTTPCookie converts to standard http.Cookie.
type PersistentJar ¶
type PersistentJar struct {
// contains filtered or unexported fields
}
PersistentJar implements http.CookieJar with SQLite persistence.
func NewPersistentJar ¶
func NewPersistentJar(store Store) (*PersistentJar, error)
NewPersistentJar creates a new persistent cookie jar.
func (*PersistentJar) Cleanup ¶
func (pj *PersistentJar) Cleanup() (int64, error)
Cleanup removes expired cookies from the store.
func (*PersistentJar) Clear ¶
func (pj *PersistentJar) Clear() error
Clear removes all cookies from jar and store.
func (*PersistentJar) ClearDomain ¶
func (pj *PersistentJar) ClearDomain(domain string) error
ClearDomain removes all cookies for a domain.
func (*PersistentJar) Cookies ¶
func (pj *PersistentJar) Cookies(u *url.URL) []*http.Cookie
Cookies implements http.CookieJar.
func (*PersistentJar) Count ¶
func (pj *PersistentJar) Count() (int64, error)
Count returns the number of stored cookies.
func (*PersistentJar) ListAll ¶
func (pj *PersistentJar) ListAll() ([]*Cookie, error)
ListAll returns all stored cookies.
func (*PersistentJar) SetCookies ¶
func (pj *PersistentJar) SetCookies(u *url.URL, cookies []*http.Cookie)
SetCookies implements http.CookieJar.
func (*PersistentJar) Store ¶
func (pj *PersistentJar) Store() Store
Store returns the underlying store (for closing).
type QueryOptions ¶
type QueryOptions struct {
Domain string // Filter by domain
Path string // Filter by path
Name string // Filter by cookie name
IncludeExpired bool // Include expired cookies
Limit int // Max results (0 = no limit)
}
QueryOptions for filtering cookies.
type Store ¶
type Store interface {
// Set stores or updates a cookie.
Set(ctx context.Context, cookie *Cookie) error
// Get retrieves a cookie by domain, path, and name.
Get(ctx context.Context, domain, path, name string) (*Cookie, error)
// List returns cookies matching the query options.
List(ctx context.Context, opts QueryOptions) ([]*Cookie, error)
// Delete removes a specific cookie.
Delete(ctx context.Context, domain, path, name string) error
// DeleteByDomain removes all cookies for a domain.
DeleteByDomain(ctx context.Context, domain string) error
// DeleteExpired removes all expired cookies and returns count.
DeleteExpired(ctx context.Context) (int64, error)
// Clear removes all cookies.
Clear(ctx context.Context) error
// Count returns total number of cookies.
Count(ctx context.Context) (int64, error)
// Close closes the store.
Close() error
}
Store defines the interface for cookie persistence.