Forces a header check for "Content-Type", "application/json"
I am testing a client that sends "content-type" with lower case C and T so this will never match
One solution could be to document the JSON method as adding a header and add a new method JSONBody
// JSON defines the JSON body to match based on a given structure, and adds a matcher for content type
func (r *Request) JSON(data interface{}) *Request {
if r.Header.Get("Content-Type") == "" {
r.Header.Set("Content-Type", "application/json")
}
return r.JSONBody(data)
}
// JSON defines the JSON body to match based on a given structure
func (r *Request) JSONBody(data interface{}) *Request {
r.BodyBuffer, r.Error = readAndDecode(data, "json")
return r
}
I tried to mock AWS SDK for Golang (aws-sdk-go/1.42.39) and noticed this problem. AWS is sending Content-Type: application/x-amz-json-1.1. I would separate totally MatchHeader from the body matching.
Forces a header check for "Content-Type", "application/json"
I am testing a client that sends "content-type" with lower case
C
andT
so this will never matchOne solution could be to document the JSON method as adding a header and add a new method JSONBody