summaryrefslogtreecommitdiff
path: root/store.go
diff options
context:
space:
mode:
authorEgon Elbre <egonelbre@gmail.com>2015-04-10 10:44:37 +0300
committerEgon Elbre <egonelbre@gmail.com>2015-04-10 10:44:37 +0300
commit14656fba266a325f977b9473fe8d2cf176944674 (patch)
treeadf7941146b5e01e88ef45f2b2a2092155560a4d /store.go
parent3e759b5c5532bec4f3934ea4c745e4ae5d69737a (diff)
Use correct path separator on Windows.
Diffstat (limited to 'store.go')
-rw-r--r--store.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/store.go b/store.go
index 13cd1db..2c0257f 100644
--- a/store.go
+++ b/store.go
@@ -9,6 +9,7 @@ import (
"io/ioutil"
"net/http"
"os"
+ "path/filepath"
"strings"
"sync"
@@ -123,9 +124,6 @@ func NewFilesystemStore(path string, keyPairs ...[]byte) *FilesystemStore {
if path == "" {
path = os.TempDir()
}
- if path[len(path)-1] != '/' {
- path += "/"
- }
return &FilesystemStore{
Codecs: securecookie.CodecsFromPairs(keyPairs...),
Options: &Options{
@@ -215,7 +213,7 @@ func (s *FilesystemStore) save(session *Session) error {
if err != nil {
return err
}
- filename := s.path + "session_" + session.ID
+ filename := filepath.Join(s.path, "session_"+session.ID)
fileMutex.Lock()
defer fileMutex.Unlock()
return ioutil.WriteFile(filename, []byte(encoded), 0600)
@@ -223,7 +221,7 @@ func (s *FilesystemStore) save(session *Session) error {
// load reads a file and decodes its content into session.Values.
func (s *FilesystemStore) load(session *Session) error {
- filename := s.path + "session_" + session.ID
+ filename := filepath.Join(s.path, "session_"+session.ID)
fileMutex.RLock()
defer fileMutex.RUnlock()
fdata, err := ioutil.ReadFile(filename)