Open Jonahss opened 7 years ago
@Jonahss This sounds like a great idea. I had always planned that we might need a way to extend the values that are interpolated, so this seems like a nice way to do it.
I'm going to ponder this a bit to consider if there are any other things we should take into account in this API. If we think that the number of things we pass might grow, we might want to pass an object and then using destructuring it is just as easy to get at what you want, yet it allows us to pass more things later.
bump
Hello,
I was looking for a module just like this one, so was glad to find it :)
In my use case, I wanted each request to have different random information in the payload, or a random header. I assumed I could pass bench-rest a function, and it would call the function each time a request is generated so that I can easily calculate different parameters each time.
Here's an example of sending different coordinates to an api endpoint that tracks the location of a package:
Notice how interpolation of the INDEX is no longer necessary, if we just have the flow defined as a function instead of a plain json object. The index can be passed in as the first argument and used by users if they choose.
Of course, the change is backwards compatible, if you pass in a plain object, it uses it. If you pass in a function it runs the function to get the object.
My implementation in this PR is a first draft. If you like the idea I can flesh-out the support and add docs.
What do you think?