You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't found any generic way to do something similar with notify.
I had a look at the code and they are few possibilities to implement this.
An easy approach would be to create a function looking like this:
package notify
import "github.com/nikoksr/notify/service/slack"
func NewServiceFromURL(url string) (Notifier, error) {
serviceName, parameters := parseURL(url)
if serviceName == "slack" {
return slack.New(...), nil
} else if (...) {
} else {
return nil, fmt.Errorf("Service %v does not exists")
}
}
Another approach with a map to store the associations would also be possible.
I wanted to open an issue first before submitting any PR to discuss about what can be implemented and what shall be avoided.
The solution above do avoid any breaking change. More elegant solutions might be possible but for now I only had ideas which are not backward-compatible.
The text was updated successfully, but these errors were encountered:
I want to migrate one of my application from shoutrrr to notify but I faced an issue: there is no way to load a service in a generic way.
With shoutrrr, a unique
CreateSender
function can be used to load any service:I haven't found any generic way to do something similar with
notify
.I had a look at the code and they are few possibilities to implement this.
An easy approach would be to create a function looking like this:
Another approach with a map to store the associations would also be possible.
I wanted to open an issue first before submitting any PR to discuss about what can be implemented and what shall be avoided.
The solution above do avoid any breaking change. More elegant solutions might be possible but for now I only had ideas which are not backward-compatible.
The text was updated successfully, but these errors were encountered: