frain-dev / convoy

The Cloud Native Webhooks Gateway
https://getconvoy.io
Mozilla Public License 2.0
2.36k stars 128 forks source link

[Feature request]: Add templating functionality for custom response #1947

Open qbx2 opened 4 months ago

qbx2 commented 4 months ago

First of all, thank you for effort to build this great product.

Is your feature request related to a problem? Please describe.

I want to solve okta's one-time verification request (https://developer.okta.com/docs/concepts/event-hooks/#one-time-verification-request) using convoy, but the challenge requires to respond with header value (x-okta-verification-challenge).

Describe the solution you'd like

Add templating functionality just like helm does. It's known to be using golang's template package (https://pkg.go.dev/text/template). It is likely to be easy to integrate and could be familiar to users.

Describe alternatives you've considered

There is a lot of template engines such as mustache, and I think it has simpler grammar.

Additional context

Okta requests with GET method for that challenge. Is it possible to support GET methods too?

linear[bot] commented 4 months ago

CON-310 [Feature request]: Add templating functionality for custom response

jirevwe commented 4 months ago

Hey @qbx2,

This is an interesting problem. We do something like this when specifying idempotency for incoming projects.

Screenshot 2024-03-09 at 15 07 16

Is this what you had in mind? Something like this?

{{ req.body.name}}, {{ req.header.x-convoy-version}}
var buf bytes.Buffer
tpl, err := template.New("file").Parse(templateFile)
if err != nil {
    return err
}

err = tpl.Execute(&buf, request)
if err != nil {
    return err
}

This change would require frontend changes, hmm. I think that's all


Also, would you be willing to open a PR for this?

qbx2 commented 4 months ago

@jirevwe Yes, that's correct. I'm sorry, but I'm busy with other work, so it won't be possible to submit a PR for the time being.

jirevwe commented 4 months ago

That's fine. We'd open a PR and link it to this issue.

qbx2 commented 4 months ago

Wow, that's so fast!! I just want to double-check that you didn't forget to support GET method to solve Okta's challenge.