Logging config

This commit is contained in:
simon987
2019-01-14 18:37:05 -05:00
parent ef333b6b25
commit 0346dd8b6b
7 changed files with 22 additions and 17 deletions

View File

@@ -3,7 +3,6 @@ package test
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
@@ -15,7 +14,7 @@ func Post(path string, x interface{}) *http.Response {
body, err := json.Marshal(x)
buf := bytes.NewBuffer(body)
r, err := http.Post("http://" + config.Cfg.ServerAddr + path, "application/json", buf)
r, err := http.Post("http://"+config.Cfg.ServerAddr+path, "application/json", buf)
handleErr(err)
return r
@@ -28,18 +27,12 @@ func Get(path string) *http.Response {
return r
}
func handleErr(err error) {
if err != nil {
panic(err)
}
}
func Print(body io.ReadCloser) {
rawBody, _ := ioutil.ReadAll(body)
fmt.Println(string(rawBody))
}
func GenericJson(body io.ReadCloser) map[string]interface{} {
var obj map[string]interface{}
@@ -50,4 +43,4 @@ func GenericJson(body io.ReadCloser) map[string]interface{} {
handleErr(err)
return obj
}
}