Skip to content

Add response correlation#17

Open
ScullWM wants to merge 1 commit into
brianmoran:masterfrom
ScullWM:master
Open

Add response correlation#17
ScullWM wants to merge 1 commit into
brianmoran:masterfrom
ScullWM:master

Conversation

@ScullWM

@ScullWM ScullWM commented Oct 3, 2018

Copy link
Copy Markdown

Hi

First thanks for this mock solution 👍

I've need to add correlation between request and response.
So basically I replace mux vars by their value in the response.
Here's a simple example from your routes.json:

{
  "routes": [
    {
      "path": "/helloworld/{key}",
      "methods": [
        "GET",
        "POST"
      ],
      "responses": [
        {
          "methods": [
            "GET",
            "POST"
          ],
          "uri": "/helloworld/foo",
          "GET": {
            "statusCode": 200,
            "body": {
              "message": "[GET] Hello {key}!"
            },
            "headers": {
              "Content-Type": "application/json"
            }
          },
          "POST": {
            "statusCode": 200,
            "body": {
              "message": "[POST] Hello {key}!"
            },
            "headers": {
              "Content-Type": "application/json"
            }
          },
          "PUT": {},
          "DELETE": {}
        }
      ]
    }
  ]
}

And so on, {key} in the response content is replaced by the request url parameter:

curl -X GET \
  http://localhost:8001/helloworld/foo
{"message":"[GET] Hello foo!"}

What do you think about it ?

@brianmoran

brianmoran commented Oct 3, 2018

Copy link
Copy Markdown
Owner

You’re welcome! Thanks for contributing!

Sorry I’m not sure what you mean. This functionality already exists. The routes path maps to the responses uri. So based on the sample routes file, if you did a request to helloworld/bar, you would get an error because there is no response mapping uri.

@ScullWM

ScullWM commented Oct 8, 2018

Copy link
Copy Markdown
Author

Oh! Is there's any solution to add correlation between request and response so ? Like re-using route pattern in responses node ?

@brianmoran

brianmoran commented Oct 8, 2018

Copy link
Copy Markdown
Owner

Oh i think I get what you are saying now. So for clarification, if the route path is /helloworld/{foo}, you are adding functionality to map a response uri /helloworld/{foo}. If you were to also add a response uri /helloworld/{baz} then you would need to add a route path for that response.

Is that a correct explanation of the new feature?

@p4tin p4tin closed this Sep 15, 2019
@p4tin p4tin reopened this Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants