WireMock:如何配置 JSON 以在响应中显示请求 headers
WireMock: How configure a JSON to show request headers in the response
我需要你的帮助来在 WireMock 中配置映射 json 文件。我有两个问题要开始:
1- 我需要在响应中看到我通过 GET 请求发送的相同 header。我只能显示一个header。我应该如何在 body 响应中添加第二个 headers 来显示它?
2- 是否可以在 body 中添加一些其他值或文本?
我有这个 json:
{
"request":
{
"urlPath": "/templated"
},
"response":
{
"body": "{{request.headers.msisdn.[0]}}",
"transformers": ["response-template"]
}
}
我运行这个:
curl -X GET \
-H ”” \
-H "msisdn: 881163662742" \
-H "client: 1c30cd57-183c-491d-a666-056fed10060a" \
http://localhost:8000/templated
我明白了:
881163662742
我想要这个作为回应:
在 body 响应中 header 的一秒钟,我尝试了这个 json 但没有成功:
{
"request":
{
"urlPath": "/templated"
},
"response":
{
"body": "{{request.headers.msisdn.[0]},{request.headers.client.[0]}}",
"transformers": ["response-template"]
}
}
如果您知道一些带有示例的网站,我将不胜感激。
谢谢!
您缺少一些 Handlebars 支架。尝试:
{{request.headers.msisdn.[0]}},{{request.headers.client.[0]}}
我需要你的帮助来在 WireMock 中配置映射 json 文件。我有两个问题要开始: 1- 我需要在响应中看到我通过 GET 请求发送的相同 header。我只能显示一个header。我应该如何在 body 响应中添加第二个 headers 来显示它? 2- 是否可以在 body 中添加一些其他值或文本?
我有这个 json:
{
"request":
{
"urlPath": "/templated"
},
"response":
{
"body": "{{request.headers.msisdn.[0]}}",
"transformers": ["response-template"]
}
}
我运行这个:
curl -X GET \ -H ”” \ -H "msisdn: 881163662742" \ -H "client: 1c30cd57-183c-491d-a666-056fed10060a" \ http://localhost:8000/templated
我明白了: 881163662742
我想要这个作为回应:
在 body 响应中 header 的一秒钟,我尝试了这个 json 但没有成功:
{
"request":
{
"urlPath": "/templated"
},
"response":
{
"body": "{{request.headers.msisdn.[0]},{request.headers.client.[0]}}",
"transformers": ["response-template"]
}
}
如果您知道一些带有示例的网站,我将不胜感激。
谢谢!
您缺少一些 Handlebars 支架。尝试:
{{request.headers.msisdn.[0]}},{{request.headers.client.[0]}}