mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-14 00:42:44 +00:00
36 lines
659 B
Go
36 lines
659 B
Go
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)
|
|
}
|