webhooked icon indicating copy to clipboard operation
webhooked copied to clipboard

feat: allow formatting the payload of webhook on the formatting module

Open 42atomys opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe

Currently we can format the stored data with the format feature but it is not possible to format the received payload.

Describe the solution you'd like

Being able to parse the payload json and then use it to extract only what is needed from the payload would be an amazing feature!

Describe alternatives you've considered

Example based on README

  formatting:
    templateString: |
      {
        "config": "{{ toJson .Config }}",
        "metadata": {
          "specName": "{{ .Spec.Name }}",
          "deliveryID": "{{ .Request.Header | getHeader "X-Delivery" | default "unknown" }}"
        },
        "payload": {{ .Payload }}
      }

We have a .Payload and send it on payload key but we can do some powerful things like following to structurate your payload as we want !

  formatting:
    templateString: |
      {
        "action": {{ .Spec.Name | default "unknown" }},
        "user_id": {{ parseJSON(.Payload).userID }},
        "user_name": "{{ parseJSON(.Payload).user.details.name }}"
      }

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

42atomys avatar Oct 07 '22 13:10 42atomys