aboutsummaryrefslogtreecommitdiffstats
path: root/gosrc/requests.go
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-04-30 20:34:07 +0200
committersalaaad2 <arthurdurant263@gmail.com>2022-04-30 20:34:07 +0200
commit6424c502b18ff2f0b263b46729b1d76585e1ad39 (patch)
treeefabeb70f39980c0e2a0f397c14753d0475c9189 /gosrc/requests.go
parentimprove response display, now with 400% more unmarshalling (smith_v_0.1.0) (diff)
downloadsmith-6424c502b18ff2f0b263b46729b1d76585e1ad39.tar.gz
smith-6424c502b18ff2f0b263b46729b1d76585e1ad39.tar.bz2
smith-6424c502b18ff2f0b263b46729b1d76585e1ad39.tar.xz
smith-6424c502b18ff2f0b263b46729b1d76585e1ad39.tar.zst
smith-6424c502b18ff2f0b263b46729b1d76585e1ad39.zip
refactor to to make space for multiple views/workspaces
Diffstat (limited to '')
-rw-r--r--gosrc/requests.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/gosrc/requests.go b/gosrc/requests.go
index 9110c89..593076b 100644
--- a/gosrc/requests.go
+++ b/gosrc/requests.go
@@ -12,6 +12,7 @@ import (
"log"
"net/http"
"strings"
+ "strconv"
)
// #include "../csrc/smith.h"
@@ -61,6 +62,7 @@ func getRequestType(name string) string {
}
}
+// display something cool
func displayResponse(node_name string, response *http.Response, output *string) {
requestType := getRequestType(node_name)
body, _ := io.ReadAll(response.Body)
@@ -80,6 +82,10 @@ func displayResponse(node_name string, response *http.Response, output *string)
"Address [" + structuredRep.Address + "]\n" +
"Url [" + structuredRep.Url + "]\n" +
"Tag [" + structuredRep.Tag + "]\n"
+ case GET_Targets.snapshot:
+ var structuredRep AccountSnapshotResponseMain
+ json.Unmarshal(body, &structuredRep)
+ outputFormatted = "code [" + strconv.FormatFloat(structuredRep.Code, 'f', 2, 64) + "]\n"
default:
outputFormatted = string(body)
}