write op working, sort of. encodes b64

This commit is contained in:
A.Unger
2020-01-31 09:36:17 +01:00
parent 31023b25b8
commit d02be70d52
2 changed files with 37 additions and 7 deletions
+18 -4
View File
@@ -2,9 +2,12 @@ package service
import (
"context"
"encoding/json"
"log"
"github.com/google/uuid"
mstore "github.com/micro/go-micro/v2/store"
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
store "github.com/owncloud/ocis-accounts/pkg/store/filesystem"
)
// New returns a new instance of Service
@@ -17,9 +20,20 @@ type Service struct{}
// Set implements the SettingsServiceHandler interface generated on accounts.pb.micro.go
func (s Service) Set(c context.Context, req *proto.Record, res *proto.Record) error {
res.Id = uuid.New().String()
res.Theme = "dark"
return nil
// uses a store manager to persist account information
st := store.New()
data, err := json.Marshal([]byte(`{"theme": "dark"}`))
if err != nil {
// deal with this accordingly and not panicking
log.Panic(err)
}
record := mstore.Record{
Key: req.Id,
Value: data,
}
return st.Write(&record)
}
// Get implements the SettingsServiceHandler interface generated on accounts.pb.micro.go