filters

package
v0.0.0-...-e086c32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter contains a number of rules. Rules are divided into rule sets, each denoted by a domain.

func (*Filter) AllowDomains

func (l *Filter) AllowDomains(types ...string) *Filter

AllowDomains sets the filter to allow only specified values as domains. The given strings are included as allowed values. Non-word values are skipped.

func (*Filter) AllowVars

func (l *Filter) AllowVars(domain string, vars ...string) *Filter

AllowVars sets the list to allow only specified values as variables for the given domain. The given strings are included as allowed values. Non-word values are skipped.

func (*Filter) Append

func (l *Filter) Append(rule string) (err error)

Append adds a rule to the filter.

func (*Filter) AsQuery

func (l *Filter) AsQuery(domain string) (query Query, err error)

AsQuery formats the rule set specified by the given domain as a SQLite query expression. Literals are replaced with parameters, and returned as arguments to be passed to the query executor.

The expression is prefixed with the AND operator. If the rule set contains no rules, then the expression is empty.

Variables are prefixed with an underscore.

type Query

type Query struct {
	// The query expression.
	Expr string
	// Values of parameters to be passed to the query.
	Params []interface{}
}

Query contains the query string and parameters of an SQLite query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL