Added files
This commit is contained in:
parent
e9ce21133a
commit
c2555a1d35
3 changed files with 33 additions and 0 deletions
26
notification/ntfy.go
Normal file
26
notification/ntfy.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package notification
|
||||
|
||||
import (
|
||||
// Standard
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type NTFY struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
func NewNTFY(config []byte) (instance NTFY, err error) {
|
||||
err = json.Unmarshal(config, &instance)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
func (ntfy NTFY) Send(msg []byte) (err error) {
|
||||
http.NewRequest("POST", ntfy.URL, bytes.NewReader(msg))
|
||||
|
||||
return
|
||||
}
|
||||
5
notification/pkg.go
Normal file
5
notification/pkg.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package notification
|
||||
|
||||
type Notification interface {
|
||||
Send([]byte) error
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue