filter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 7 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	QueryKeyFilterExpression = "q"
)

Variables

View Source
var (
	ErrFilter = errors.New("filter error")
)

Functions

func BuildQuery

func BuildQuery(expression query.FilterExpression) (map[string]string, error)

func FilterError

func FilterError(cause string) error

func ParseQuery

func ParseQuery(q map[string]string) (query.FilterExpression, error)

func ParseQueryWithTransform

func ParseQueryWithTransform(q map[string]string, transformer Transformer) (query.FilterExpression, error)

Types

type Operation

type Operation string
const (
	OperationAND Operation = "and"
	OperationOR  Operation = "or"
	OperationNOT Operation = "not"
)

type RequestQueryParser

type RequestQueryParser struct {
	Transformer Transformer
}

func NewRequestQueryParser

func NewRequestQueryParser(options ...func(*RequestQueryParser)) RequestQueryParser

func (RequestQueryParser) ParseFilterQuery

func (p RequestQueryParser) ParseFilterQuery(r *http.Request) (query.FilterExpression, error)

type Transformer

type Transformer interface {
	TransformFilterToken(*query.Filter) (query.FilterExpression, error)
}

type TransformerFunc

type TransformerFunc func(*query.Filter) (query.FilterExpression, error)

func (TransformerFunc) TransformFilterToken

func (f TransformerFunc) TransformFilterToken(t *query.Filter) (query.FilterExpression, error)

type TransformerMux

type TransformerMux struct {
	Strict       bool
	Transformers map[string]Transformer
}

func (TransformerMux) TransformFilterToken

func (t TransformerMux) TransformFilterToken(token *query.Filter) (query.FilterExpression, error)

Jump to

Keyboard shortcuts

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