ab.go 895 字节
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))
}