cmp

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCMPVendorList = "https://cmplist.consensu.org/v2/cmp-list.json"
)

Variables

View Source
var (
	ValidCMPs []int
)

Functions

This section is empty.

Types

type CMP

type CMP struct {
	ID           int
	Name         string
	IsCommercial bool
	Environments []string
}

CMP contains the structure of the CMP info that comes inside the JSON

type Consent struct{}

func (*Consent) IsCMPListLoaded

func (c *Consent) IsCMPListLoaded() bool

IsCMPListLoaded returns if the list of valid CMPs was loaded or not.

func (*Consent) ValidCMPs

func (c *Consent) ValidCMPs() []int

ValidCMPs returns the list of valid CMPs loaded.

type Loader

type Loader struct {
	URL  string
	JSON string
}

Loader is the type that contains the logic to load and parse a CMP JSON list.

func NewLoader

func NewLoader(options ...Option) *Loader

NewLoader returns a CMP vendor list loader instance.

func (*Loader) Load

func (loader *Loader) Load() ([]CMP, error)

Load decides which CMP list we are going to load.

func (*Loader) LoadHTTP added in v0.4.0

func (loader *Loader) LoadHTTP() ([]CMP, error)

LoadHTTP is used to load the vendor list from a HTTP url.

func (*Loader) LoadIDs

func (loader *Loader) LoadIDs() error

LoadIDs loads the list of vendor CMP ids globally so we can reuse it with subsequent calls.

func (*Loader) LoadJSON added in v0.4.0

func (loader *Loader) LoadJSON() ([]CMP, error)

LoadJSON is used to load the vendor list from a received JSON string.

func (*Loader) Unmarshal

func (loader *Loader) Unmarshal(data []byte) ([]CMP, error)

Unmarshal parses the JSON vendor list into a struct so we can use them.

type Option

type Option func(loader *Loader)

Option is the type that allows us to configure the Loader dynamically.

func WithJSON added in v0.4.0

func WithJSON(json string) Option

WithJSON allows to pass a JSON string loaded externally so our loader will parse the cmp-list JSON format for you.

func WithURL

func WithURL(url string) Option

WithURL allows to configure a different URL for the CMP JSON list.

Jump to

Keyboard shortcuts

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