stubby4node
stubby4node copied to clipboard
Default file?
I have to create a fallback response for some endpoints and I currently use body option for that. But those responses are quite long (SOAP responses) and it is quite painful to add them to json config file.
Would it be possible to add a default file option so that I could externalise this default response for better readability?
Thanks!
You can use the file
option for the response so that you aren't writing SOAP in json or yaml
I am using. I route to correct response file, but if it is not found then body response is used. Only thing is that body response may be long and would be good if that could be file as well.
It sounds like you want the fallback to your non-existent file
option to also be a file
instead of just the regular body
option?
Yes! This is how I use it now
"response": {
"status": 200,
"file": "data/some_pattern_file_<% post[2] %>_<% post[1] %>.xml",
"body": "<soapenv:Envelope some really long xml response here... it is really long and ugly believe me :D"
}
and this is how I really want to use
"response": {
"status": 200,
"file": "data/some_pattern_file_<% post[2] %>_<% post[1] %>.xml",
"body": "data/default.xml"
}
I'll accept a pull request that allows file:
to be a String
or Array
of filepaths in order of fall-back precedence.
response:
status: 200
file:
- "first/file.json"
- "second/file.json"