ab.go
895 字节
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
package controllers
import (
"github.com/astaxie/beego"
"github.com/tiptok/gocomm/pkg/mybeego"
"gitlab.fjmaimaimai.com/mmm-go/ab/protocol"
"gitlab.fjmaimaimai.com/mmm-go/ab/services/ab"
)
type ABController struct {
BaseController
}
var aHost string
var bHost string
const (
QueryResponseError = 1 //请求应答错误
CompareResultSuccess = 2 //应答对比成功
CompareResultError = 3 //应答对比错误
)
func init() {
aHost = beego.AppConfig.String("AHost")
bHost = beego.AppConfig.String("BHost")
}
//Compare
func (this *ABController) Compare() {
var msg *mybeego.Message
defer func() {
this.Resp(msg)
}()
request := &protocol.CompareRequest{
Method: this.Ctx.Request.Method,
RequestUri: this.Ctx.Request.RequestURI,
Head: this.Ctx.Request.Header,
Body: this.ByteBody,
IsRetry: true,
}
msg = this.GenMessage(ab.Compare(request))
}