Skip to content
Snippets Groups Projects

Develop

Closed Ghost User requested to merge develop into master
1 file
+ 8
5
Compare changes
  • Side-by-side
  • Inline
+ 8
5
@@ -3,11 +3,12 @@ package cli
import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"io/ioutil"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
const apiRoot = "?"
@@ -26,6 +27,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
resp, err := http.Get(apiEndpoint + apiRoot + "q=" + f + builder.String())
if err != nil {
log.Info(fmt.Sprintf("Err: %s", err))
return err
}
builder.Reset()
@@ -38,8 +40,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
switch f {
case "init":
pnd := string(bytes[:36])
sbi := string(bytes[36:])
pnd := string(bytes[9:45])
sbi := string(bytes[55:91])
viper.Set("CLI_PND", pnd)
viper.Set("CLI_SBI", sbi)
err := viper.WriteConfig()
@@ -49,6 +51,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
default:
fmt.Println(string(bytes))
}
case http.StatusCreated:
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
@@ -58,8 +61,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
uuid := string(bytes[19:55])
viper.Set("LAST_DEVICE_UUID", uuid)
fmt.Println(string(bytes))
case http.StatusAccepted:
case http.StatusAccepted:
default:
log.WithFields(log.Fields{
"status code": resp.StatusCode,
Loading