commonformatter

package
Version: v0.0.0-...-86d60f8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptySep = errors.New("empty sep")
View Source
var FindFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	c := &RegexpConfig{}
	err := loader(c)
	if err != nil {
		return nil, err
	}
	return c.CreateFindFormatter()
})
View Source
var IntegerFormatter = httpinfo.FormatterFunc(func(data []byte) ([]byte, bool, error) {
	_, err := strconv.Atoi(string(data))
	if err != nil {
		return nil, false, nil
	}
	return data, true, nil
})
View Source
var IntegerFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	return IntegerFormatter, nil
})
View Source
var MatchFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	c := &RegexpConfig{}
	err := loader(c)
	if err != nil {
		return nil, err
	}
	return c.CreateMatchFormatter()
})
View Source
var SplitFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	f := &SplitFormatter{}
	err := loader(f)
	if err != nil {
		return nil, err
	}

	return f, nil
})
View Source
var ToLowerFormatter = StringsFormatter(strings.ToLower)
View Source
var ToLowerFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	return ToLowerFormatter, nil
})
View Source
var ToUpperFormatter = StringsFormatter(strings.ToUpper)
View Source
var ToUpperFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	return ToUpperFormatter, nil
})
View Source
var TrimSpaceFormatter = StringsFormatter(strings.TrimSpace)
View Source
var TrimSpaceFormatterFactory = httpinfomanager.FormatterFactoryFunc(func(loader func(interface{}) error) (httpinfo.Formatter, error) {
	return TrimSpaceFormatter, nil
})

Functions

func RegisterFactories

func RegisterFactories()

Types

type FindFormatter

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

func (FindFormatter) Format

func (f FindFormatter) Format(data []byte) ([]byte, bool, error)

type MatchFormatter

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

func (MatchFormatter) Format

func (f MatchFormatter) Format(data []byte) ([]byte, bool, error)

type RegexpConfig

type RegexpConfig struct {
	Pattern string
	Index   int
}

func (*RegexpConfig) CreateFindFormatter

func (c *RegexpConfig) CreateFindFormatter() (*FindFormatter, error)

func (*RegexpConfig) CreateMatchFormatter

func (c *RegexpConfig) CreateMatchFormatter() (*MatchFormatter, error)

type SplitFormatter

type SplitFormatter struct {
	Sep   string
	Index int
}

func (*SplitFormatter) Format

func (f *SplitFormatter) Format(data []byte) ([]byte, bool, error)

type StringsFormatter

type StringsFormatter func(string) string

func (StringsFormatter) Format

func (f StringsFormatter) Format(data []byte) ([]byte, bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL