wiremock/wiremock

Support returning HTTP 404 when mapping files aren't found.

開放

#2,470 建立於 2023年10月31日

 (1 則留言) (1 個反應) (0 位負責人)Java (1,368 個分叉)batch import
enhancementhelp wanted

倉庫指標

星標
 (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

貢獻者指南