From e73eb1162ab4ecdb6bbf1337c8c0ef95dbe0e2bf Mon Sep 17 00:00:00 2001 From: r Date: Sat, 21 Dec 2019 09:56:18 +0000 Subject: Use json format for app and session repo --- repository/appRepository.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'repository/appRepository.go') diff --git a/repository/appRepository.go b/repository/appRepository.go index 00ef64d..cfa7950 100644 --- a/repository/appRepository.go +++ b/repository/appRepository.go @@ -1,6 +1,7 @@ package repository import ( + "encoding/json" "web/kv" "web/model" ) @@ -16,7 +17,11 @@ func NewAppRepository(db *kv.Database) *appRepository { } func (repo *appRepository) Add(a model.App) (err error) { - err = repo.db.Set(a.InstanceDomain, a.Marshal()) + data, err := json.Marshal(a) + if err != nil { + return + } + err = repo.db.Set(a.InstanceDomain, data) return } @@ -27,7 +32,10 @@ func (repo *appRepository) Get(instanceDomain string) (a model.App, err error) { return } - err = a.Unmarshal(instanceDomain, data) + err = json.Unmarshal(data, &a) + if err != nil { + return + } return } -- cgit v1.2.3