1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-09 22:50:05 +00:00
cloudkeys-go/dataObject.go

37 lines
659 B
Go
Raw Permalink Normal View History

2015-07-29 07:01:23 +00:00
package main
import (
"bytes"
"encoding/gob"
"encoding/json"
"io"
)
type authorizedAccounts []authorizedAccount
type authorizedAccount struct {
Name string
UserFile string
}
func init() {
gob.Register(authorizedAccounts{})
}
type dataObject struct {
MetaData struct {
Version string `json:"version"`
Password string `json:"password"`
} `json:"metadata"`
Data string `json:"data"`
}
func readDataObject(in io.Reader) (*dataObject, error) {
t := &dataObject{}
return t, json.NewDecoder(in).Decode(t)
}
func (d *dataObject) GetData() (io.Reader, error) {
buf := bytes.NewBuffer([]byte{})
return buf, json.NewEncoder(buf).Encode(d)
}