domains

package module
v0.0.0-...-94f59a9 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package domains provides utilities that help when working with domains

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map map[string]interface{}

Map is a map that maps domain names to some other data

type Tree

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

Tree is a radix-tree that supports domain-based matching including wildcard prefixes (specified with a leading .)

func NewTree

func NewTree() *Tree

NewTree constructs a new empty Tree

func NewTreeFromMap

func NewTreeFromMap(initial Map) *Tree

NewTreeFromMap constructs a Tree initialized from a given Map

func (*Tree) BestMatch

func (tree *Tree) BestMatch(domain string) (result interface{}, found bool)

BestMatch finds the best match for the given domain

func (*Tree) Get

func (tree *Tree) Get(domain string) (result interface{}, found bool)

Get gets the entry exactly matching the given domain

func (*Tree) Insert

func (tree *Tree) Insert(domain string, value interface{})

Insert inserts a new value into the tree

func (*Tree) ToMap

func (tree *Tree) ToMap() Map

ToMap obtains the Tree as a Map

func (*Tree) Walk

func (tree *Tree) Walk(fn func(domain string, value interface{}) bool)

Walk walks the tree, calling the supplied fn for each domain/value pair in the tree and continuing the walk as long as fn returns true.

Jump to

Keyboard shortcuts

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