returns literal null as a response body instead of an empty body.
PS: to be honest, I think this entire if block is redundant because it makes the behavior inconsistent between dynamic-response mocks and static-response mocks: in static-response mocks we only allow strings as body and don't convert arbitrary objects into strings.
This if has been added because without it, the user should escape all the quotation marks when he wants to return a json object in a go_template script which makes the mocks more difficult to read and write.
Check that body is not nil before serializing it to json. This fixes an issue where a mock like this
returns literal
null
as a response body instead of an empty body.PS: to be honest, I think this entire
if
block is redundant because it makes the behavior inconsistent between dynamic-response mocks and static-response mocks: in static-response mocks we only allow strings asbody
and don't convert arbitrary objects into strings.