After you have installed NodeJS and ran npm install
:
node bin/index --target=http://targethost.com --port=5001 (optional)
Where port
is the port the proxy server will listen on and target
is the server to which calls that are not mocked will be proxied. The port
defaults to 5001
.
It is also possible to supply a separate swaggerHost
in case you want the Swagger UI's "try-it-out" feature to work and localhost
is not the address at which the server will be available publicly - for instance if your application is deployed on AWS. If you don't supply this parameter, localhost
is assumed
as a host and the port is either 5001
or the value of port
.
node bin/index --target=http://targethost.com --port=5001 --swaggerHost=http://www.anotherhost.com:5002/somePath
The logs will report where the Swagger endpoint can be reached.
Method:
PUT
/proxy/setMockResponse
{
"url": "/the/url/to/override",
"statusCode": 500,
"body": {
"sample": "response"
},
"responseHeaders": {
"key": "value",
},
delay : 2000,
times: 5
}
Setting a delay and/or a number of times are both optional! If no delay is given, it defaults to 0. If no number of times is given, it defaults to ∞.
Method:
POST
Set multiple delays at once. This will also affect existing mock responses!
/proxy/setDelays
{
"delays": [
{
"url": "/url",
"delay": 2000
},
{
"url": "/anotherurl",
"delay": 5000
}
]
}
Method:
DELETE
/proxy/clearMockResponse
{
"url": "/the/mock/url/to/remove"
}
/proxy/clearAllMockResponses
Method:
DELETE
Method:
DELETE
Clear all delays. Does NOT clear any mock responses however!
/proxy/clearAllDelays
Method:
GET
Generate a list of all the requests that have been proxied through the proxy server and their responses, if any.
/proxy/listProxiedRequests?limit=50
limit
The maximum number of requests, defaults to ∞.
Method:
GET
Generate a map with all the mock responses that have been set for given URLs. The value in the map for a given key is the number of times that mock response was returned.
/proxy/listMockResponses
Method:
DELETE
/proxy/clearProxiedCalls