Documentation ¶
Index ¶
- Constants
- func IsAlreadyLearnedError(err error) bool
- func IsNotFound(err error) bool
- func New(url string, options ...Option) *client
- func NewFromClient(restyClient *resty.Client) *client
- func NewMock() *mockClient
- func ReaderFromWriterTo(writerTo io.WriterTo) io.Reader
- func SetFlag(header http.Header, flag int)
- func SetQueueID(header http.Header, queueID string)
- func SetWeight(header http.Header, weight int)
- type CheckRequest
- type CheckResponse
- type Client
- type FuzzyRequest
- type FuzzyResponse
- type LearnRequest
- type LearnResponse
- type Option
- type PingResponse
- type SymbolData
- type UnexpectedResponseError
Constants ¶
const ( QueueID = "Queue-Id" Flag = "Flag" Weight = "Weight" )
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyLearnedError ¶
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.
func New ¶
New returns a client. It takes the url of a rspamd instance, and configures the client with Options which are closures.
func NewFromClient ¶
func NewFromClient(restyClient *resty.Client) *client
NewFromClient returns a client. It takes an instance of resty.Client.
func NewMock ¶
func NewMock() *mockClient
NewMock creates a mock client, which can be used wherever client is used, to test/
func SetQueueID ¶
Types ¶
type CheckRequest ¶
CheckRequest encapsulates the request of Check.
type CheckResponse ¶
type CheckResponse struct { Score float64 `json:"score"` Action string `json:"action"` 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, *CheckRequest) (*CheckResponse, error) LearnSpam(context.Context, *LearnRequest) (*LearnResponse, error) LearnHam(context.Context, *LearnRequest) (*LearnResponse, error) FuzzyAdd(context.Context, *FuzzyRequest) (*FuzzyResponse, error) FuzzyDel(context.Context, *FuzzyRequest) (*FuzzyResponse, error) Ping(context.Context) (PingResponse, error) }
Client is a rspamd HTTP client.
type FuzzyRequest ¶
FuzzyRequest encapsulates the request of FuzzyAdd, FuzzyDel.
type FuzzyResponse ¶
FuzzyResponse encapsulates the response of FuzzyAdd, FuzzyDel.
type LearnRequest ¶
LearnRequest encapsulates the request of LearnSpam, LearnHam.
type LearnResponse ¶
type LearnResponse struct {
Success bool `json:"success"`
}
LearnResponse encapsulates the response of LearnSpam, LearnHam.
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 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 ¶
type UnexpectedResponseError struct {
Status int
}
func (*UnexpectedResponseError) Error ¶
func (e *UnexpectedResponseError) Error() string