ruletree

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 4 more Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data added in v0.9.0

type Data interface {
	ShouldMatchRes(res *http.Response) bool
	ShouldMatchReq(req *http.Request) bool
	ParseModifiers(modifiers string) error
}

type RuleTree

type RuleTree[T Data] struct {
	// contains filtered or unexported fields
}

RuleTree is a trie-based filter that is capable of parsing Adblock-style and hosts rules and matching URLs against them.

The filter is safe for concurrent use.

func NewRuleTree

func NewRuleTree[T Data]() *RuleTree[T]

func (*RuleTree[T]) Add added in v0.9.0

func (rt *RuleTree[T]) Add(urlPattern string, data T) error

func (*RuleTree[T]) FindMatchingRulesReq

func (rt *RuleTree[T]) FindMatchingRulesReq(req *http.Request) (data []T)

FindMatchingRulesReq finds all rules that match the given request.

func (*RuleTree[T]) FindMatchingRulesRes

func (rt *RuleTree[T]) FindMatchingRulesRes(req *http.Request, res *http.Response) (rules []T)

FindMatchingRulesRes finds all rules that match the given response. It assumes that the request that generated the response has already been matched by FindMatchingRulesReq.

Jump to

Keyboard shortcuts

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