Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyLearnedError ¶ added in v1.1.0
IsAlreadyLearnedError returns true if a request returns 208, which can happen if rspamd detects a message has already been learned as SPAM/HAM. This can allow clients to gracefully handle this use case.
func IsNotFound ¶
IsNotFound returns true if a request returned a 404. This helps discern a known issue with rspamd's /checkv2 endpoint.
Types ¶
type CheckResponse ¶
type CheckResponse struct { Score float64 `json:"score"` MessageID string `json:"message-id"` Symbols map[string]SymbolData `json:"symbols"` }
CheckResponse encapsulates the response of Check.
type Client ¶
type Client interface { Check(context.Context, *Email) (*CheckResponse, error) LearnSpam(context.Context, *Email) (*LearnResponse, error) LearnHam(context.Context, *Email) (*LearnResponse, error) FuzzyAdd(context.Context, *Email) (*LearnResponse, error) FuzzyDel(context.Context, *Email) (*LearnResponse, error) Ping(context.Context) (PingResponse, error) }
Client is a rspamd HTTP client.
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email represents an abstract type holding the email content and headers to pass to rspamd.
func NewEmailFromReader ¶
NewEmailFromWriterTo creates an Email instance from an io.Reader.
func NewEmailFromWriterTo ¶
NewEmailFromWriterTo creates an Email instance from an io.WriterTo.
func (*Email) Flag ¶
Flag attaches a flag to an Email, and eventually as a header when sent to rspamd. Flag identifies fuzzy storage.
type LearnResponse ¶
type LearnResponse struct {
Success bool `json:"success"`
}
LearnResponse encapsulates the response of LearnSpam, LearnHam, FuzzyAdd, FuzzyDel.
type Option ¶
type Option func(*client) error
Option is a function that configures the rspamd client.
func Credentials ¶
Credentials sets the credentials passed in parameters. It returns an Option which is used to configure the client.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options encapsulate headers the client can pass in requests to rspamd.
type SymbolData ¶
type SymbolData struct { Name string `json:"name"` Score float64 `json:"score"` MetricScore float64 `json:"metric_score"` Description string `json:"description"` }
SymbolData encapsulates the data returned for each symbol from Check.
type UnexpectedResponseError ¶ added in v1.2.0
type UnexpectedResponseError struct {
Status int
}
func (*UnexpectedResponseError) Error ¶ added in v1.2.0
func (e *UnexpectedResponseError) Error() string