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

Is there any way to configure the value of the response?

artefactop opened this issue · comments

Hi,

I would like to use this to mock an external API, my question is I can configure the response, for example:

POST Request with Body {"element_id": 2}
Response {"element_id": 2, "deleted":true}

Where value of element_id match in request and response.

Hi @artefactop,

It depends on what you're looking for:

  • If you want to define different responses based on the element_id (e.g. if it is 2 then return 2 and deleted equals to true; if it is 3 then return 3 and deleted equals to false); the response would be: YES.
  • If you want to dynamically re-use the element_id on the response (e.g. the response should contain the element_id value present on the request, without specifying which one), then it's: NO.

You can find some examples in our documentation about how to define dynamic responses based on either regexes or JSON schemas, for instance.

Does that clarify you question?

Thanks!

Yes, thank you. I was looking for the second behavior you explain. 😢