Skip to content

Feature Request - support parsing of request.path #128

Description

@briantist

Unlike the body for example, we can't do intensive parsing of the path. The .regex() and .concat() methods don't work on the path.

The :value part of the path also cannot be limited to specific values, so you can't simultaneously get a particular part of path while limiting which values match.

As an example, I have a config like this:

request:
  method: POST|PUT
  path: "/api/v1/method/create*/resource"

I want to match create*, so create or create-thing or create-other would be valid for that part of the path.

In the response, I want to reference that component, or part of it. I'd like to use regex maybe:

response:
  statusCode: 200
  headers:
    Content-Type:
      - application/json
  body: 'A request to create {{request.path.regex(/create-([^/]*)/)}} has been received.'

However that doesn't work.

If I instead do:

request:
  method: POST|PUT
  path: "/api/v1/method/:method/resource"

then I guess I can do:

response:
  statusCode: 200
  headers:
    Content-Type:
      - application/json
  body: 'A request to {{request.path.method}} has been received.'

Which is something.. but not quite the same, as I can't do any string manipulation on it.

But even worse, is that the config will match paths I don't want it to match, like /api/v1/method/delete/resource.

It seems that my only option is hardcoding the possible permutations of paths I want to match into multiple configs, with a lot of duplication and slightly different responses. The data I need isn't in the body of the request, so it seems like I'm stuck.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions