gstroup / apimocker

node.js module to run a simple http server for mock service responses.
MIT License
280 stars 80 forks source link

Fix retrieval of switch parameter in request #93

Closed twalker closed 6 years ago

twalker commented 6 years ago

A recent change to how a switch value was accessed from a request introduced a regression bug: https://github.com/gstroup/apimocker/commit/5df065d0be7600a895e3a555fe7e6c918f9b8c44

That commit replaced the deprecated req.param(key) function in Express v3, which would get a parameter value from the route parameters, request body, or querystring. It was replaced with req.query, which does not retrieve values from the route parameters (req.params). So mocked routes that used route params (e.g. v2/position/:lang/:id) would not return the file designated by the route parameter value (e.g. v2/id376217.position.json)

This PR uses a getRequestParam utility function to retrieve a switch value from the body, route params, querystring, or header. It fixes #91

gstroup commented 6 years ago

Thanks for catching my mistake!

twalker commented 6 years ago

No problem, I'm happy to make a small contribution.

aburmeis commented 6 years ago

Thanks a lot, great I can use the next release again!