Add "status" request helper#894
Conversation
|
Thank you for opening this PR. I will review and probably add some remarks. I saw that the linter is failing. Maybe correct this first so we can run all the tests. |
|
I realized that this helper is not compatible with the data buckets as they are generated during server start, or during the first call. |
* Add "status" request helper (#894) * Add "status" request helper * test added * test null condition flag on dataRaw helper * fix minor lint issue * set status code from template on sendFile * Remove data helper modifications from PR * Move response helpers in separated file, use express response locals * fix test Co-authored-by: Dashie <dashie@users.noreply.github.com>
- Remove old docs and add images for latest version - Update release changelog - Add doc for mockoon/mockoon#873 - Add details about faker.js seeding - Add folders doc - Add serverless infos - Add doc for mockoon/mockoon#894 - Add docs for query params
Technical implementation details
I want to propose this new helper. The impact is very little and it is simple to be used, but can be very useful in many cases.
The idea is to be able to set the response status inside the template.
Imagine a route like this:
and a data bucket with name
testdataand the following content:now using a template like this:
we have a routes where we can return 200 with data if the data exists in the bucket
or 404 if the data does not exist.
To be able to check the path selection I've also added an optional flag on
dataRawhelper, that return an empty string""when the selection path does not match any property.If you accept this proposal I can finish it with tests and docs :P
Checklist