dataview

package
v0.18.0-beta07 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKvViewValueIsNotAString = errors.New("value is not a string")
	ErrKvViewEntryNotFound     = errors.New("entry not found")
)
View Source
var (
	ErrMalformedData = errors.New("malformed data")
)

Functions

func JsonValidator

func JsonValidator(v []byte) error

JsonValidator returns nil if input is valid json and ErrMalformedData otherwise.

Types

type Data

type Data []byte

Data define a slice of byte encoded.

type FasthttpArgsKeysValuesCollector

type FasthttpArgsKeysValuesCollector struct {
	Args           *fasthttp.Args
	Prefix         string
	ValueValidator func([]byte) error
}

FasthttpArgsKeysValuesCollector implements KvCollector. FasthttpArgsKeysValuesCollector collects values whose key have given prefix as raw string.

func (FasthttpArgsKeysValuesCollector) CollectKeysValues

func (fakvc FasthttpArgsKeysValuesCollector) CollectKeysValues() (keys, values []string, err error)

CollectKeysValues implements keysValuesCollector.

type FasthttpArgsKvView

type FasthttpArgsKvView struct {
	Args *fasthttp.Args
}

FasthttpArgsKvView is KvView implementation based on *fasthttp.Args.

func (FasthttpArgsKvView) GetString

func (fakv FasthttpArgsKvView) GetString(key string) (string, error)

type JsonData

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

JsonData define data that is potentially encoded as JSON value.

func NewJsonData

func NewJsonData(data Data) *JsonData

NewJsonData creates a new JsonData holding given untrusted inner data.

func (*JsonData) Data

func (jd *JsonData) Data() (Data, error)

Data returns underlying data and a nil error if it contains a well formed JSON.

type JsonKvCollector

type JsonKvCollector struct {
	Json *JsonData
	Path string
}

JsonKvCollector collects keys and values from a JSON object. Values are raw JSON encoded value: string values will contains quotes.

func (JsonKvCollector) CollectKeysValues

func (jkc JsonKvCollector) CollectKeysValues() (keys, values []string, err error)

CollectKeysValues implements KvCollector. JsonKvCollector collects values as raw JSON encoded string: string value will contains quotes.

type JsonKvView

type JsonKvView struct {
	Json *JsonData
}

JsonKvView is a KvView implementation over a JSON object.

func (JsonKvView) GetString

func (jkv JsonKvView) GetString(key string) (string, error)

GetString implements KvView.

type KvCollector

type KvCollector interface {
	CollectKeysValues() (keys, values []string, err error)
}

KvCollector define objects that can collect a set of keys and values.

type KvView

type KvView interface {
	GetString(string) (string, error)
}

KvView is a view over a set of key values.

Jump to

Keyboard shortcuts

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