xxxxxxx
This commit is contained in:
parent
b751fc5eb4
commit
61af9f0c8b
5 changed files with 118 additions and 65 deletions
44
storage/files/files.go
Normal file
44
storage/files/files.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Package files implements sessions saved into filesystem persistently encoded using gob
|
||||
package files
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
sessDir string = "go-session"
|
||||
sessExt string = "gsd"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
}
|
||||
|
||||
// ProviderFiles implement filesystem session provider
|
||||
type ProviderFiles struct {
|
||||
sessPath string
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func (pder *ProviderFiles) ckdir() string {
|
||||
return pder.sessPath + sessDir
|
||||
}
|
||||
|
||||
// SetParams for files session provider set base path in filesystem for save sessions
|
||||
func (pder *ProviderFiles) SetParams(p any) (err error) {
|
||||
if p != nil {
|
||||
if s, ok := p.(string); ok {
|
||||
pder.sessPath = s
|
||||
return
|
||||
}
|
||||
return fmt.Errorf("Parameter for files session provider is not string")
|
||||
}
|
||||
return fmt.Errorf("Parameter for files session provider must not be nil")
|
||||
}
|
||||
|
||||
// Init create session file if not exists and retturn *Session
|
||||
func (pder *ProviderFiles) Init(sid string) (err error) {
|
||||
//sessdir := sid + sessExt
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue