Middleware

March 25, 2019 ยท View on GitHub

For validation and self controlled responses you can select middleware as response. The middleware function will be called, in case of "middleware" is selected. It's response can be a string which will continue with the given string as selected response. If you return null or undefined you have to implement the response by yourself.

example

Parameter[0] serverOptions

See node-mock-server options

Parameter[1] requestOptions

attributetypedescription
reqObjectThe (request object)[http://expressjs.com/en/api.html#req].
resObjectThe (response object)[http://expressjs.com/en/api.html#res].
methodstringContains a string corresponding to the HTTP method of the request: GET, POST, PUT, and so on.
dirstringThe directory of selected response
preferencesObjectThe preferences object