Support returning HTTP 404 when mapping files aren't found.
#2,470 创建于 2023年10月31日
仓库指标
- 星标
- (5,766 个星标)
- PR 合并指标
- (平均合并 1天 15小时) (30 天内合并 33 个 PR)
描述
Proposal
Right now, WireMock returns an HTTP 500 when it finds a matching response mapping, but that response mapping contains a reference to a file that doesn't exist.
In certain cases, the desired behaviour might be to return an HTTP 404, for example when we create a generic mapping containing a reference to a social security number and we have a set of files containing predefined response bodies for certain SSNs.
To clarify, here's an example JSON response mapping that basically acts as a lookup for a local folder containing response body files:
{
"request": {
"method": "GET",
"urlPathPattern": "/some-endpoint/.*"
},
"response": {
"status": 200,
"bodyFileName": "some-path/{{request.path.[1]}}.json",
"transformers": ["response-template"]
}
}
I'm not proposing that the default behaviour for WireMock should be to return a 404 in all cases where the file isn't found, but there are definitely use cases for it.
References
No response