aboutsummaryrefslogtreecommitdiffstats
path: root/gosrc/requests.go
diff options
context:
space:
mode:
Diffstat (limited to 'gosrc/requests.go')
-rw-r--r--gosrc/requests.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/gosrc/requests.go b/gosrc/requests.go
index 6df7bc6..9110c89 100644
--- a/gosrc/requests.go
+++ b/gosrc/requests.go
@@ -7,6 +7,8 @@
package main
import (
+ "encoding/json"
+ "io"
"log"
"net/http"
"strings"
@@ -59,6 +61,31 @@ func getRequestType(name string) string {
}
}
+func displayResponse(node_name string, response *http.Response, output *string) {
+ requestType := getRequestType(node_name)
+ body, _ := io.ReadAll(response.Body)
+ var outputFormatted string
+
+ switch (requestType) {
+ case GET_Targets.status:
+ var structuredRep AccountStatusResponse
+ json.Unmarshal(body, &structuredRep)
+ outputFormatted =
+ "Status [" + structuredRep.Data + "]\n"
+ case GET_Targets.address:
+ var structuredRep DepositAddressResponse
+ json.Unmarshal(body, &structuredRep)
+ outputFormatted =
+ "Coin [" + structuredRep.Coin + "]\n" +
+ "Address [" + structuredRep.Address + "]\n" +
+ "Url [" + structuredRep.Url + "]\n" +
+ "Tag [" + structuredRep.Tag + "]\n"
+ default:
+ outputFormatted = string(body)
+ }
+ *output = outputFormatted
+}
+
// Sign payload using openssl
func signRequest(body string, key string) string {
// run pipeline