improve session of file storage for ghttp.Server

This commit is contained in:
John
2019-11-07 20:42:13 +08:00
parent a3fd0c9a4a
commit 9da1277b47

View File

@ -255,10 +255,13 @@ func (s *Server) Start() error {
// Default session storage.
if s.config.SessionStorage == nil {
path := gfile.Join(s.config.SessionPath, s.name)
if !gfile.Exists(path) {
if err := gfile.Mkdir(path); err != nil {
glog.Fatalf("mkdir failed for '%s':", path, err)
path := ""
if s.config.SessionPath != "" {
path = gfile.Join(s.config.SessionPath, s.name)
if !gfile.Exists(path) {
if err := gfile.Mkdir(path); err != nil {
glog.Fatalf("mkdir failed for '%s':", path, err)
}
}
}
s.config.SessionStorage = gsession.NewStorageFile(path)