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
}