diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-06-21 16:54:46 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-06-21 16:54:46 +0200 |
| commit | 24be04cf37dbbeaf7fa33fa027ea6b54823e21f2 (patch) | |
| tree | 5394f8b13e6713167c7e2fc0db133143ef4c84e6 /internal/server | |
| parent | 1393ab1888e50cf623d22a8135daf42bda333f99 (diff) | |
Server: Add the ability to get the saved servers
Diffstat (limited to 'internal/server')
| -rw-r--r-- | internal/server/server.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index ce72400..807bd09 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -1,6 +1,7 @@ package server import ( + "encoding/json" "fmt" "github.com/jwijenbergh/eduvpn-common/internal/fsm" @@ -68,6 +69,16 @@ func (servers *Servers) GetCurrentServer() (Server, error) { return institute, nil } +func (servers *Servers) GetJSON() (string, error) { + bytes, bytesErr := json.Marshal(servers) + + if bytesErr != nil { + return "", bytesErr + } + + return string(bytes), nil +} + type Servers struct { InstituteServers InstituteServers `json:"institute_servers"` SecureInternetHomeServer SecureInternetHomeServer `json:"secure_internet_home"` |
