Proxy
plugin-proxy
The main distribution includes the plugin-proxy plugin preinstalled. It provides a route handler that proxy requests to another host and pass response back.
This is very useful when developing integration tests, for example, because you can redirect requests to the original host and modify its responses. So, you can start developing integration tests before the real API is modified according to the new contract.
Options
The proxy
route handler uses the express-http-proxy package under the hood, and supports all of its options.
Mocks server common properties to all variants are in cursive. Specific properties of the proxy handler are in bold:
id
(String): Id of the route variant.handler
(String): Must be "proxy".delay
(Number|null): Milliseconds of delay for this variant.host
(String|Function): The proxy host. Equivalent to theexpress-http-proxy
host
option, so it can also be a function.options
(Object): Object containing any of the options supported by theexpress-http-proxy
package. Some of them are:filter
(Function):filter
option forexpress-http-proxy
.userResDecorator
(Function):userResDecorator
option forexpress-http-proxy
.- ... all other
express-http-proxy
options are also supported.
Tip: Note that the
delay
option is still valid, so you can use it to simulate that host responses are slow.
Usage
Read the proxy route variants guide to get some suggestions about how to use it.