diff options
author | r <r@freesoftwareextremist.com> | 2019-12-21 09:56:18 +0000 |
---|---|---|
committer | r <r@freesoftwareextremist.com> | 2019-12-21 10:56:40 +0000 |
commit | e73eb1162ab4ecdb6bbf1337c8c0ef95dbe0e2bf (patch) | |
tree | b6350d31333acc58d763218c8f1cd1098755b05a /model/app.go | |
parent | a25d64a0785c3da4bedfa69aefb78a28369b6012 (diff) | |
download | bloat-e73eb1162ab4ecdb6bbf1337c8c0ef95dbe0e2bf.tar.gz bloat-e73eb1162ab4ecdb6bbf1337c8c0ef95dbe0e2bf.zip |
Use json format for app and session repo
Diffstat (limited to 'model/app.go')
-rw-r--r-- | model/app.go | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/model/app.go b/model/app.go index 89d656d..7abc8ec 100644 --- a/model/app.go +++ b/model/app.go @@ -2,7 +2,6 @@ package model import ( "errors" - "strings" ) var ( @@ -10,31 +9,13 @@ var ( ) type App struct { - InstanceDomain string - InstanceURL string - ClientID string - ClientSecret string + InstanceDomain string `json:"instance_domain"` + InstanceURL string `json:"instance_url"` + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` } type AppRepository interface { Add(app App) (err error) Get(instanceDomain string) (app App, err error) } - -func (a *App) Marshal() []byte { - str := a.InstanceURL + "\n" + a.ClientID + "\n" + a.ClientSecret - return []byte(str) -} - -func (a *App) Unmarshal(instanceDomain string, data []byte) error { - str := string(data) - lines := strings.Split(str, "\n") - if len(lines) != 3 { - return errors.New("invalid data") - } - a.InstanceDomain = instanceDomain - a.InstanceURL = lines[0] - a.ClientID = lines[1] - a.ClientSecret = lines[2] - return nil -} |