Documentation
¶
Index ¶
- Constants
- Variables
- func Notify(msg *LogMessage)
- type Color
- type Dispatcher
- type GotifyClient
- type GotifyMessage
- type LogField
- type LogFields
- type LogMessage
- type NotificationConfig
- type Ntfy
- type NtfyStyle
- type Provider
- type ProviderBase
- func (base *ProviderBase) GetMIMEType() string
- func (base *ProviderBase) GetMethod() string
- func (base *ProviderBase) GetName() string
- func (base *ProviderBase) GetToken() string
- func (base *ProviderBase) GetURL() string
- func (base *ProviderBase) SetHeaders(logMsg *LogMessage, headers http.Header)
- func (base *ProviderBase) Validate() E.Error
- type ProviderConfig
- type ProviderCreateFunc
- type Webhook
Constants ¶
View Source
const ( ProviderGotify = "gotify" ProviderNtfy = "ntfy" ProviderWebhook = "webhook" )
Variables ¶
View Source
var ( ErrMissingToken = E.New("token is required") ErrURLMissingScheme = E.New("url missing scheme, expect 'http://' or 'https://'") )
Functions ¶
func Notify ¶
func Notify(msg *LogMessage)
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func StartNotifDispatcher ¶
func StartNotifDispatcher(parent task.Parent) *Dispatcher
func (*Dispatcher) RegisterProvider ¶
func (disp *Dispatcher) RegisterProvider(cfg *NotificationConfig)
type GotifyClient ¶
type GotifyClient struct {
ProviderBase
}
func (*GotifyClient) GetURL ¶
func (client *GotifyClient) GetURL() string
func (*GotifyClient) MakeBody ¶
func (client *GotifyClient) MakeBody(logMsg *LogMessage) (io.Reader, error)
MakeBody implements Provider.
type GotifyMessage ¶
type GotifyMessage model.MessageExternal
type LogMessage ¶
type NotificationConfig ¶
type NotificationConfig struct { ProviderName string `json:"provider"` Provider Provider `json:"-"` }
func (*NotificationConfig) UnmarshalMap ¶
func (cfg *NotificationConfig) UnmarshalMap(m map[string]any) (err E.Error)
UnmarshalMap implements MapUnmarshaler.
type Ntfy ¶
type Ntfy struct { ProviderBase Topic string `json:"topic"` Style NtfyStyle `json:"style"` }
See https://docs.ntfy.sh/publish
func (*Ntfy) GetMIMEType ¶
func (*Ntfy) SetHeaders ¶
func (n *Ntfy) SetHeaders(logMsg *LogMessage, headers http.Header)
type Provider ¶
type Provider interface { utils.CustomValidator GetName() string GetURL() string GetToken() string GetMethod() string GetMIMEType() string MakeBody(logMsg *LogMessage) (io.Reader, error) SetHeaders(logMsg *LogMessage, headers http.Header) // contains filtered or unexported methods }
type ProviderBase ¶
type ProviderBase struct { Name string `json:"name" validate:"required"` URL string `json:"url" validate:"url"` Token string `json:"token"` }
func (*ProviderBase) GetMIMEType ¶
func (base *ProviderBase) GetMIMEType() string
func (*ProviderBase) GetMethod ¶
func (base *ProviderBase) GetMethod() string
func (*ProviderBase) GetName ¶
func (base *ProviderBase) GetName() string
func (*ProviderBase) GetToken ¶
func (base *ProviderBase) GetToken() string
func (*ProviderBase) GetURL ¶
func (base *ProviderBase) GetURL() string
func (*ProviderBase) SetHeaders ¶
func (base *ProviderBase) SetHeaders(logMsg *LogMessage, headers http.Header)
func (*ProviderBase) Validate ¶
func (base *ProviderBase) Validate() E.Error
Validate implements the utils.CustomValidator interface.
type ProviderConfig ¶
type Webhook ¶
type Webhook struct { ProviderBase Template string `json:"template"` Payload string `json:"payload"` Method string `json:"method"` MIMEType string `json:"mime_type"` ColorMode string `json:"color_mode"` }
func (*Webhook) GetMIMEType ¶
GetMIMEType implements Provider.
Click to show internal directories.
Click to hide internal directories.