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

Handlebar helpers should have access to gRPC metadata #189

Closed
ledouxpl opened this issue Sep 2, 2022 · 1 comment
Closed

Handlebar helpers should have access to gRPC metadata #189

ledouxpl opened this issue Sep 2, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request released

Comments

@ledouxpl
Copy link

ledouxpl commented Sep 2, 2022

Is your feature request related to a problem? Please describe.
I am unable to perform request matching on gRPC metadata as I am able to do for a HTTP request.

Concretely, I am unable to provide a localized response by honouring the accept-language header which we pass through gRPC metadata.

Describe the solution you'd like
Handlebar helpers should have access to the gRPC request metadata.

Describe alternatives you've considered
Considered modyfing GrpcParser.ts to forward to Handlebar's context the grpc metadata as such:

const fileContent = await template({ request: call.request, metadata: call.metadata });

Then modyfing RequestHelper.ts to provide support for them in the capture helper as such:

case "metadata":
    return context.data.root.metadata.get(context.hash.key);

Enabling me to create a gRPC mock as:

{{#is 'en-US' 'in' (capture from='metadata' key='accept-language') }}
{
    "id": {{num_between lower=500 upper=600}},
    "title": "from matching header!"
}
{{else}}
{
    "id": {{num_between lower=500 upper=600}},
    "title": "no matching header :(",
}
{{/is}}
@ledouxpl ledouxpl added the enhancement New feature or request label Sep 2, 2022
shubhendumadhukar added a commit that referenced this issue Oct 25, 2022
* fix: move @types/js-yaml to dev deps

* fix: upgrade convert-csv-to-json

* deps: bump express to 4.18.1

* deps: bump fs-extra to latest

* deps: bump logform

* deps: bump moment

* deps: bump node-cron

* deps: bump pg

* fix: pass grpc metadata to helpers. Closes #189

* fix: generic parsing of express requests to string

* feat: implemented initial version of schema validation. Closes #195 (#196)

* feat: implemented initial version of schema validation #195

* chore: tweaks after review #195

* doc: added a validation section in the docs #195

* doc: added a validation section in the docs #195

* fix/ignore lint errors

Co-authored-by: Richard Ruiter <richard@inorm.nl>
@github-actions
Copy link

🎉 This issue has been resolved in version 0.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
Development

No branches or pull requests

2 participants