The functionality behind the behaviors field in the API, supporting post-processing responses
- Source:
Methods
(inner) copy(originalRequest, response, copyConfig, logger) → {Object}
Copies a value from the request and replaces response tokens with that value
Parameters:
Name | Type | Description |
---|---|---|
originalRequest |
Object | The request object, in case post-processing depends on it |
response |
Object | The response |
copyConfig |
function | The config to copy |
logger |
Object | The mountebank logger, useful in debugging |
- Source:
Returns:
- Type
- Object
(inner) decorate(originalRequest, response, fn, logger, imposterState) → {Object}
Runs the response through a post-processing function provided by the user
Parameters:
Name | Type | Description |
---|---|---|
originalRequest |
Object | The request object, in case post-processing depends on it |
response |
Object | The response |
fn |
function | The function that performs the post-processing |
logger |
Object | The mountebank logger, useful in debugging |
imposterState |
Object | The user controlled state variable |
- Source:
Returns:
- Type
- Object
(async, inner) execute(request, response, behaviors, logger, imposterState) → {Object}
The entry point to execute all behaviors provided in the API
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | The request object |
response |
Object | The response generated from the stubs |
behaviors |
Object | The behaviors specified in the API |
logger |
Object | The mountebank logger, useful for debugging |
imposterState |
Object | the user-controlled state variable |
- Source:
Returns:
- Type
- Object
(async, inner) lookup(originalRequest, response, lookupConfig, logger) → {Object}
Looks up request values from a data source and replaces response tokens with the resulting data
Parameters:
Name | Type | Description |
---|---|---|
originalRequest |
Object | The request object |
response |
Object | The response |
lookupConfig |
function | The lookup configurations |
logger |
Object | The mountebank logger, useful in debugging |
- Source:
Returns:
- Type
- Object
(inner) shellTransform(request, response, command, logger) → {Object}
Runs the response through a shell function, passing the JSON in as stdin and using
stdout as the new response
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | The request |
response |
Object | The response |
command |
string | The shell command to execute |
logger |
Object | The mountebank logger, useful in debugging |
- Source:
Returns:
- Type
- Object
(inner) validate(config) → {Object}
Validates the behavior configuration and returns all errors
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | The behavior configuration |
- Source:
Returns:
The array of errors
- Type
- Object
(async, inner) wait(request, response, millisecondsOrFn, logger) → {Object}
Waits a specified number of milliseconds before sending the response. Due to the approximate
nature of the timer, there is no guarantee that it will wait the given amount, but it will be close.
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | The request object |
response |
Object | The response |
millisecondsOrFn |
number | The number of milliseconds to wait before returning, or a function returning milliseconds |
logger |
Object | The mountebank logger, useful for debugging |
- Source:
Returns:
A promise resolving to the response
- Type
- Object