Skip to content
Snippets Groups Projects
Commit 89c6de45 authored by Sydney Anne Erickson's avatar Sydney Anne Erickson :chipmunk:
Browse files

Download dApp and error JSONs

parent a5ecfc1a
No related branches found
No related tags found
2 merge requests!53Release,!25Download dApp and error JSONs
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2021 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package bindings
import (
"io/ioutil"
"net/http"
)
// Returns a []byte containing the JSON data describing client errors.
// See https://git.xx.network/elixxir/client-error-database/
func DownloadErrorDB() ([]byte, error) {
// Build a request for the file
resp, err := http.Get("https://elixxir-bins.s3-us-west-1.amazonaws.com/client/errors/clientErrors.json")
if err != nil {
return nil, err
}
defer resp.Body.Close()
// Download the contents of the file
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
// Return it to the user
return content, nil
}
// Returns a []byte containing the JSON data describing registered dApps.
// See https://git.xx.network/elixxir/registered-dapps
func DownloadDAppRegistrationDB() ([]byte, error) {
// Build a request for the file
resp, err := http.Get("https://elixxir-bins.s3-us-west-1.amazonaws.com/client/dapps/appdb.json")
if err != nil {
return nil, err
}
defer resp.Body.Close()
// Download the contents of the file
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
// Return it to the user
return content, nil
}
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2021 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package bindings
import (
"fmt"
"testing"
)
func TestDownloadErrorDB(t *testing.T) {
json, err := DownloadErrorDB()
if err != nil {
t.Errorf("DownloadErrorDB returned error: %s", err)
}
fmt.Printf("json: %s\n", string(json))
}
func TestDownloadDAppRegistrationDB(t *testing.T) {
json, err := DownloadDAppRegistrationDB()
if err != nil {
t.Errorf("DownloadDAppRegistrationDB returned error: %s", err)
}
fmt.Printf("json: %s\n", string(json))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment