contrib icon indicating copy to clipboard operation
contrib copied to clipboard

Simple "plugin" framework using templates *feature*

Open furyfire opened this issue 5 years ago • 5 comments

Since the Go language natively support a fairly advanced template engine why not allow for "plugins" to be created using templates alone?

https://push.example.de/message?token=&template=github-webhook

Gotify would then parse the incomming JSON and apply the "github-webhook" template.

This would allow for an easy way of using webhooks and quickly parsing out one or two fields. Just my two cents # #

furyfire avatar Mar 12 '19 08:03 furyfire

I think instead of having built-in support for that, we can actually write a plugin to do that:)

We can accept text/template to parse HTTP header/body and translate it into a formatted message. Golang text/template has a relatively lightweight syntax and is easy to get on:)

eternal-flame-AD avatar Mar 12 '19 08:03 eternal-flame-AD

Glad you agree It feels like overkill having to write a separate plugin for every webhook there is. And currently there is no way of making gotify accept a randomly formatted json object

furyfire avatar Mar 12 '19 08:03 furyfire

@jmattheis Do you think we should have a built-in template engine, or it should exist as a plugin is?

eternal-flame-AD avatar Mar 12 '19 09:03 eternal-flame-AD

@furyfire Actually we don't need to do so. We can write a single plugin that listens on different URLs for messages, and use different predefined or custom templates to format messages from arbitrary json/plain object.

eternal-flame-AD avatar Mar 12 '19 09:03 eternal-flame-AD

It feels like overkill having to write a separate plugin for every webhook there is. And currently there is no way of making gotify accept a randomly formatted json object

Yes and no, some webhooks require validation of the message this would add additional calls which cannot easily be generalized.

I agree with @eternal-flame-AD here, lets add a single plugin which supports multiple webhooks / webhook templating.

jmattheis avatar Mar 14 '19 17:03 jmattheis