Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serve URLparam-based files #52

Closed
erichorne opened this issue Aug 28, 2018 · 3 comments
Closed

serve URLparam-based files #52

erichorne opened this issue Aug 28, 2018 · 3 comments
Assignees
Labels
feature New feature request need feedback Feedback from the requester/community is needed

Comments

@erichorne
Copy link

Sometimes, APIs have a lookup service whereby an object can be retrieved from the service by something like an 'id'. It could return a wide variety of responses that can be difficult to template into a single file.

To make it easier to mock, one idea is to have each of the varied responses available as a file itself so that requests to …/lookup/:id load a filename from the system based on that :id parameter. For example, /lookup/abc123 could load the template abc123.json, or maybe it loads abc123-GET.json.

The solution I'd like to see here is to support the JSON templating language in the filename specification for a route.

Alternatives to this idea include just supporting url parameters in the filename specification. Supporting an include statement within the template that could assemble the response by including parts of the response from other files could also prove very flexible and easier to implement.

@255kb 255kb added the feature New feature request label Oct 18, 2018
@255kb 255kb added the need feedback Feedback from the requester/community is needed label Nov 7, 2018
@255kb
Copy link
Member

255kb commented Nov 7, 2018

I think that adding templating support in the file path input would be sufficient, what do you think?
First step would be to allow input edition, second step allow templating. So you could browser for a file and write something like this:
c:/folder/user_data_{{routeParam 'userId'}}.json
What do you think?

@255kb 255kb self-assigned this Nov 7, 2018
@255kb 255kb added this to the Next release milestone Nov 7, 2018
@255kb
Copy link
Member

255kb commented Nov 11, 2018

I realize that this is exactly what you proposed :)
So, it's implemented for the next release, I will also add an option to be able to serve a file OR get the file content and put in in the response body instead.

@erichorne
Copy link
Author

sounds great! Thank you!

@255kb 255kb closed this as completed in e3a0366 Dec 16, 2018
@255kb 255kb removed this from the Next release milestone Dec 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request need feedback Feedback from the requester/community is needed
Projects
None yet
Development

No branches or pull requests

2 participants