Basic client library for ntfy.sh service.
- Go 100%
|
|
||
|---|---|---|
| .markdownlint.json | ||
| .prettierrc | ||
| go.mod | ||
| LICENSE | ||
| ntfy.go | ||
| README.md | ||
| renovate.json | ||
Go client for ntfy.sh
This is a basic client for ntfy.sh service.
Install
go get -u code.thinkaboutit.tech/pandora/ntfysh.gopack
Example to use
Send a basic push notification:
package main
import (
"fmt"
"log/slog"
"os"
ntfy "code.thinkaboutit.tech/pandora/ntfysh.gopack"
)
func main() {
client := ntfy.NewNtfyClient("https://ntfy.sh", nil)
// Optional, if no authentication setup then no auth will be used.
client.SetAuthBasic("myuser", "mypassword")
msg := ntfy.Message{
Topic: ntfy.AsPtr("my-topic"),
Message: ntfy.AsPtr("my message"),
Title: ntfy.AsPtr("my title"),
}
response, err := client.Push(msg)
if err != nil {
slog.Error("failed push message", "error", err.Error())
os.Exit(1)
}
fmt.Printf("%+v\n", response)
}