scorewr

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package scorewr provides a wrapper for RBLs that inserts scores into responses.

This package is a work in progress and makes no API stability promises.

Index

Constants

View Source
const WrapperClass = "score"

WrapperClass defines default class name of component builder.

Variables

This section is empty.

Functions

func Builder

func Builder(defaultCfg Config) xlistd.BuildWrapperFn

Builder returns a builder function.

Types

type Config

type Config struct {
	Scores []ScoreExpr
}

Config options.

type ScoreExpr

type ScoreExpr struct {
	RegExp *regexp.Regexp
	Score  int
}

ScoreExpr defines score matching.

func (ScoreExpr) Match

func (e ScoreExpr) Match(s string) bool

Match returns true if matching.

type Wrapper

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

Wrapper implements an xlist.Checker wrapper for insert scores.

func New

func New(list xlistd.List, score int, cfg Config) *Wrapper

New returns a new Wrapper.

func (*Wrapper) Check

func (w *Wrapper) Check(ctx context.Context, name string, resource xlist.Resource) (xlist.Response, error)

Check implements xlist.Checker interface.

func (*Wrapper) Class

func (w *Wrapper) Class() string

Class implements xlistd.List interface.

func (*Wrapper) ID

func (w *Wrapper) ID() string

ID implements xlistd.List interface.

func (*Wrapper) Ping

func (w *Wrapper) Ping() error

Ping implements xlistd.List interface.

func (*Wrapper) Resources

func (w *Wrapper) Resources(ctx context.Context) ([]xlist.Resource, error)

Resources implements xlist.Checker interface.

Jump to

Keyboard shortcuts

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