1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-29 15:57:09 +00:00

Implement a file-storage session database for https://github.com/kataras/iris/issues/702 (UNTESTED)

Former-commit-id: 7ca4183ee0602936d8270d6e7dac6bec3d3fa2b5
This commit is contained in:
kataras
2017-08-02 20:53:17 +03:00
parent 2b6af256fa
commit 6fb90cfdb4
2 changed files with 87 additions and 2 deletions

View File

@@ -88,7 +88,7 @@ func (d *Database) Update(sid string, newValues map[string]interface{}, expireDa
}
// SerializeBytes serializa bytes using gob encoder and returns them
// SerializeBytes serialize the "m" into bytes using the gob encoder and returns the result.
func SerializeBytes(m interface{}) ([]byte, error) {
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
@@ -99,7 +99,7 @@ func SerializeBytes(m interface{}) ([]byte, error) {
return nil, err
}
// DeserializeBytes converts the bytes to an object using gob decoder
// DeserializeBytes converts the bytes to a go value and puts that to "m" using the gob decoder.
func DeserializeBytes(b []byte, m interface{}) error {
dec := gob.NewDecoder(bytes.NewBuffer(b))
return dec.Decode(m) //no reference here otherwise doesn't work because of go remote object