diff auth/session.go @ 340:4c211ad5349e

Embed Reader and Writer in BinReader and BinWriter to make API more distinct.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 05 Aug 2018 15:48:36 +0200
parents 33b59c848771
children ac23905e64b1
line wrap: on
line diff
--- a/auth/session.go	Sun Aug 05 15:35:29 2018 +0200
+++ b/auth/session.go	Sun Aug 05 15:48:36 2018 +0200
@@ -43,11 +43,11 @@
 }
 
 func (s *Session) serialize(w io.Writer) error {
-	wr := misc.BinWriter{W: w}
-	wr.Write(s.ExpiresAt)
+	wr := misc.BinWriter{w, nil}
+	wr.WriteBin(s.ExpiresAt)
 	wr.WriteString(s.User)
 	wr.WriteString(s.Password)
-	wr.Write(uint32(len(s.Roles)))
+	wr.WriteBin(uint32(len(s.Roles)))
 	for _, role := range s.Roles {
 		wr.WriteString(role)
 	}
@@ -57,11 +57,11 @@
 func (s *Session) deserialize(r io.Reader) error {
 	var x Session
 	var n uint32
-	rd := misc.BinReader{R: r}
-	rd.Read(&x.ExpiresAt)
+	rd := misc.BinReader{r, nil}
+	rd.ReadBin(&x.ExpiresAt)
 	rd.ReadString(&x.User)
 	rd.ReadString(&x.Password)
-	rd.Read(&n)
+	rd.ReadBin(&n)
 	x.Roles = make(Roles, n)
 	for i := uint32(0); n > 0 && i < n; i++ {
 		rd.ReadString(&x.Roles[i])