question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use URI path parameters on the response template

See original GitHub issue

Is it possible to use URL parameters in path and insert them in the response template, as URL queries?

For some mocks, I see the need to insert values coming from the URL path.

For example:

  • URI: /v1/test/.*/example
  • Request: GET /v1/test/dummy/example
  • Response: dummy

Maybe something like the following:

    {
        "request": {
            "uri": {
                "match": "/v1/test/.*/example"
            },
            "method": "get",
        },
        "response": {
            "status": 200,
            "text": {
                "template": "{$req.uri.param[0]}"
            },
            "headers": {
                "Content-Type": "application/json"
            }
        }
    },

Thanks.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dreamheadcommented, Dec 4, 2022

@wapcrazut Your feature request has been included in release 1.4.0. https://github.com/dreamhead/moco/blob/master/moco-doc/apis.md#path-2

1reaction
dreamheadcommented, Sep 6, 2022

This feature is not supported for now.

I do want to implement this feature, that’s like Spring RequestMapping parsing, as following:

{
        "request": {
            "uri": {
                "path": "/v1/test/{foo-id}/example"
            },
            "method": "get",
        },
        "response": {
            "status": 200,
            "text": {
                "template": "{$req.uri.path.foo-id}"
            },
            "headers": {
                "Content-Type": "application/json"
            }
        }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

how to use URI templates to change path parameters in a ...
1 Answer 1 ... If you are using .build for filling the template, you have to provide the values one by one like...
Read more >
Add URI Parameters to Spring WebClient Requests - amitph
A guide to add Request URI parameters - path parameters & query parameters to the requests made by Spring WebFlux WebClient.
Read more >
URI Templates - Apiary Help
URI Templates are handy for expressing variables within a URL, such as a path variable or a query variable. This is done through...
Read more >
The @Path Annotation and URI Path Templates
The @Path annotation identifies the URI path template to which the resource responds, and is specified at the class level of a resource....
Read more >
Understanding the URI Param and Query Param With RAML
URI parameter (Path Param) is basically used to identify a specific resource or resources whereas Query Parameter is used to sort/filter those ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found