craftcms / webhooks

Plugin for integrating Craft with Zapier and IFTTT.
https://plugins.craftcms.com/webhooks
MIT License
84 stars 12 forks source link

[FR] Add ability to customize the webhook URL using Twig and element attributes #18

Closed rungta closed 5 years ago

rungta commented 5 years ago

It would be useful if the webhook URL can also be set dynamically and had access to the event variable that triggered it. That would enable use cases such as automatically purging and/or warming cache after an entry is saved.

{{ url('/_purge/' ~ event.sender.url) }}

Where /_purge/<url> would purge the Nginx FastCGI cache for <url>. Similarly, we could request that page again via a webhook in order to warm up the cache.

brandonkelly commented 5 years ago

Just added this, plus environment variable support, for the next release.

You can get the change ahead of time by changing your craftcms/webhooks requirement in composer.json to:

"require": {
  "craftcms/webhooks": "dev-develop#d38709eb1d4ac7dfb169865bbcc33f938255be89 as 2.2.0",
  "...": "..."
}

Then run composer update.

rungta commented 5 years ago

That was quick. Thanks @brandonkelly!

2mas commented 4 years ago

Exactly what I need when wanting to refresh cache on multisite/headless solution. However it did not seem to work until i did your trick with the composer-file @brandonkelly, despite docs says it should work which confused me a bit. Is this maybe forgotten to be released or coming up in a later version? (I noticed the 2.2.0 release here is from 29 of july and the fix is made in august)

brandonkelly commented 4 years ago

Webhooks 2.3.0 is out now with this change.