/
helpers.go
43 lines (37 loc) · 1.16 KB
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2018 The ClientSDK Team Authors. All rights reserved.
// Use of this source code is governed by a Apache 2.0-style
// license that can be found in the LICENSE file.
// Author: ClientSDK Team (muharihar)
package sjwsdk111
import (
"fmt"
"log"
)
// DebugHTTP is function to debug HTTP Request/Response
func DebugHTTP(data []byte, err error) {
if err == nil {
fmt.Printf("%s\n\n", data)
} else {
log.Fatalf("%s\n\n", err)
}
}
// DebugHTTPRequest is a function to debug HTTP Request
func DebugHTTPRequest(data []byte, err error) {
fmt.Println("[DEBUG]:: DebugHTTPRequest")
fmt.Println("=============================")
fmt.Println("Request: ")
fmt.Println("-----------------------------")
DebugHTTP(data, err)
fmt.Println("-----------------------------")
fmt.Println("End-Request: ")
}
// DebugHTTPResponse is a function to debug HTTP Response
func DebugHTTPResponse(data []byte, err error) {
fmt.Println("[DEBUG]:: DebugHTTPResponse")
fmt.Println("=============================")
fmt.Println("Response: ")
fmt.Println("-----------------------------")
DebugHTTP(data, err)
fmt.Println("-----------------------------")
fmt.Println("End-Response: ")
}