killgrave icon indicating copy to clipboard operation
killgrave copied to clipboard

Callback Service Call

Open guvense opened this issue 4 years ago • 4 comments

When the mock server gets a request after a while sends a request to the given url. This feature might be useful for 3rd API service which works with send notifications. I prepared case:

    {
        "request": {
            "method": "GET",
            "endpoint": "/gophers/01D8EMQ185CA8PRGE20DKZTGSR"            
        },
        "callback": {
            "request": {
                "method": "GET",
                "endpoint": "http://localhost:8089/v1",
                "headers": {
                    "Content-Type": "application/json"
                },
                "body": "{\"test\": \"test\"}"
                    
            },
            "delay" : "5s:10s"
        },
        "response": {
            "status": 200,
            "headers": {
                "Content-Type": "application/json"
            },
            "body": "{\"data\":{\"type\":\"gophers\",\"id\":\"01D8EMQ185CA8PRGE20DKZTGSR\",\"attributes\":{\"name\":\"Zebediah\",\"color\":\"Purples\",\"age\":55}}}"
        }
    }
]

when request get by mock server after given delay, it will send request to "http://localhost:8089/v1"" As mentioned I prepared codes then it works.

guvense avatar Oct 01 '21 13:10 guvense

Hello @guvense thanks for the idea, could you share a real use case for that purpouse, I understand what do you want to achive with this, but I'm not sure is a real problem to solve using mock server, so if you can explain a little bit more the use case would be great :D

aperezg avatar Oct 02 '21 21:10 aperezg

Hello @aperezg, in my case when the mock server gets a request, it should push the event to Kafka. Because I try to mock a service which put request to queue and process request in order. Therefore mock server returns a response after some time it should push the event to kafka. At the same time, my real application listens to kafka.

Another case, some third-party application. notify the status of the request. It can be the status of a money transaction. I will give an endpoint to the mock server, after some delay mock server sends a request about the transaction. Therefore I can simulate it. We can also add sse service, pushing events to Kafka sending HTTP request anything in the callback field.

guvense avatar Oct 03 '21 20:10 guvense

We need that as well. We are developing a payment system. We trigger another 3-rd party by HTTP call, and that API returns a callback to us. The structure of the configuration is precisely the same, as @guvense suggested.

musinit avatar Aug 14 '23 19:08 musinit

hello @guvense can u assign this to me

#146

peacewalker122 avatar Aug 28 '23 12:08 peacewalker122