wiremock/wiremock

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

Aperta

#2470 aperta il 31 ott 2023

 (1 commento) (1 reazione) (0 assegnatari)Java (1368 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (5766 stelle)
Metriche merge PR
 (Merge medio 1g 15h) (33 PR mergiate in 30 g)

Descrizione

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

Guida contributor