ab.go
1.1 KB
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
44
45
46
47
48
49
package protocol
import (
"encoding/json"
"github.com/tiptok/gocomm/pkg/log"
)
/*Compare */
type CompareRequest struct {
Method string
RequestUri string
Head map[string][]string
Body []byte
IsRetry bool
}
type CompareResponse struct {
}
type Request struct {
Host string `json:"-"`
Method string `json:"method"`
RequestUri string `json:"request_uri"`
Head map[string][]string `json:"head"`
Body interface{} `json:"body"`
AResp interface{} `json:"a_resp"`
BResp interface{} `json:"b_resp"`
Result bool `json:"result"`
}
func NewRequest(host, method, requestUri string, head map[string][]string, body []byte) Request {
var mapBody = make(map[string]interface{})
json.Unmarshal(body, &mapBody)
return Request{
//Host:host,
Method: method,
RequestUri: requestUri,
Head: head,
Body: mapBody,
Result: false,
}
}
func (req Request) GetBody() []byte {
data, err := json.Marshal(req.Body)
if err != nil {
log.Error(err)
return []byte{}
}
return data
}