Skip to content

Commit

Permalink
Add comments for GobCodec
Browse files Browse the repository at this point in the history
  • Loading branch information
alexedwards committed May 3, 2020
1 parent 37d1d39 commit b1338f6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ type Codec interface {
Decode([]byte) (deadline time.Time, values map[string]interface{}, err error)
}

// GobCodec is used for encoding/decoding session data to and from a byte
// slice using the encoding/gob package.
type GobCodec struct{}

// Encode converts a session dealine and values into a byte slice.
func (GobCodec) Encode(deadline time.Time, values map[string]interface{}) ([]byte, error) {
aux := &struct {
Deadline time.Time
Expand All @@ -33,6 +36,7 @@ func (GobCodec) Encode(deadline time.Time, values map[string]interface{}) ([]byt
return b.Bytes(), nil
}

// Decode converts a byte slice into a session deadline and values.
func (GobCodec) Decode(b []byte) (time.Time, map[string]interface{}, error) {
aux := &struct {
Deadline time.Time
Expand Down

0 comments on commit b1338f6

Please sign in to comment.