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

feat(service): add generic webhook service #144

Merged
merged 5 commits into from
Apr 2, 2021
Merged

Conversation

piksel
Copy link
Member

@piksel piksel commented Mar 6, 2021

This adds a custom webhook service that just posts the message to the URL that corresponds to the URL.

To use it with another format, set the template query field (generic://example.com/api/webhook?template=TEMPLATE_ID or pass it as a param to Send:

err = service.Send("Message", &types.Params{"template": "TEMPLATE_ID"})

The templates are loaded into the service by using either

err := service.SetTemplateString("TEMPLATE_ID", `{{.message}}`)

or

err := service.SetTemplateFile("TEMPLATE_ID", "/path/to/template.file")

Where TEMPLATE_ID can be anything.

this makes it possible to ignore errors setting
config props and defaults
@codecov
Copy link

codecov bot commented Mar 6, 2021

Codecov Report

Merging #144 (58ed40d) into main (469140f) will increase coverage by 4.33%.
The diff coverage is 85.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
+ Coverage   63.98%   68.32%   +4.33%     
==========================================
  Files          70       72       +2     
  Lines        1999     2096      +97     
==========================================
+ Hits         1279     1432     +153     
+ Misses        606      547      -59     
- Partials      114      117       +3     
Impacted Files Coverage Δ
pkg/format/format_query.go 78.12% <79.16%> (+78.12%) ⬆️
pkg/format/prop_key_resolver.go 76.92% <80.00%> (+76.92%) ⬆️
pkg/services/generic/generic.go 83.78% <83.78%> (ø)
pkg/services/generic/generic_config.go 93.54% <93.54%> (ø)
pkg/router/servicemap.go 100.00% <100.00%> (ø)
pkg/format/node.go 91.17% <0.00%> (+0.73%) ⬆️
pkg/format/formatter.go 66.66% <0.00%> (+3.33%) ⬆️
pkg/format/enum_formatter.go 70.00% <0.00%> (+10.00%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 469140f...58ed40d. Read the comment docs.

@piksel piksel requested a review from simskij March 6, 2021 21:34
@piksel piksel linked an issue Mar 6, 2021 that may be closed by this pull request
@piksel piksel added this to the v0.5.0 milestone Mar 6, 2021
@piksel piksel merged commit 0f8a531 into main Apr 2, 2021
@piksel piksel deleted the feature/generic-service branch April 2, 2021 13:55
piksel added a commit that referenced this pull request May 14, 2021
* feat(format): improve default props handling
this makes it possible to ignore errors setting
config props and defaults

* feat(service): add generic webhook service
* docs(generic): add some basic docs
* test(format): add and split additional tests
* docs: fix broken markdown formatting
piksel added a commit that referenced this pull request May 14, 2021
* feat(format): improve default props handling
this makes it possible to ignore errors setting
config props and defaults

* feat(service): add generic webhook service
* docs(generic): add some basic docs
* test(format): add and split additional tests
* docs: fix broken markdown formatting
@piksel piksel modified the milestones: v0.6.0, v0.5.0 Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add generic webhook service
1 participant