write op working, sort of. encodes b64
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user