friendsofgo / killgrave

Simple way to generate mock servers written in Go

Home Page:https://friendsofgo.github.io/killgrave/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow setting different responses per request (repeats)

joanlopez opened this issue · comments

Context

A quite common feature on some of the mock servers of the market is the possibility to define a different response for each time an imposter is requested.

It basically will consists on returning the response A the first X times the imposter is requested, then returning the response B the next times and so on (as much flexible as possible).

Proposed implementation

As this is an issue tagged as just an idea, there's no implementation proposal.
Then, there's a single requirement: to keep Killgrave as simple as possible.

Example

Just as a proposal example,

It could be implemented by changing the response section (within imposter) from an object to an array of objects, adding to each of them a field times (or named similar) that would allow the user to set those different responses for each request.

However, it's entirely open, so feel free to write down a comment with your point-of-view and to start the discussion.

Hi, I think it could be done, define an arrangement with a series of predefined responses around 2 to 4, and then send them randomly :)

Hey,

Yup, we're completely open to suggestions. Maybe we can define multiple response mechanisms.
IMHO, both (the one defined on the issue description and the one you mentioned) can coexist.

What do you think? 🤔
cc/ @aperezg

@aperezg You could assign it to me, I would like to keep trying?

@aperezg Could you tell me an idea of how the user could choose the option he wants, I came to think of creating a sub endpoint so to speak but I think it would break the simple scheme that killgrave wants to maintain

@joanlopez is this issue still open?
I'd like to start working on this one but I see in the documentation that we support dynamic responses and this issue is still open.

@joanlopez is this issue still open?
I'd like to start working on this one but I see in the documentation that we support dynamic responses and this issue is still open.

Yes, this issue is still open because though Killgrave allows you to set up dynamic responses based on request's matching rules, you cannot set up dynamic responses for one specific set of matching rules.

You can look at the aforementioned PR comments from @aperezg to get additional context.

I've done some work on the above feature request. I've added changes related information in the PR's comment.
@joanlopez and/or @aperezg, can you please take a look?

Here's a link to my PR

commented

Is it still open? Would like to work on it.

Is it still open? Would like to work on it.

Yeah, although I think the work done by @infinite-spectrum can definitely be reused (with his credits, ofc), it was probably close to be "mergeable".