converter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CastNumber

type CastNumber struct {
	Name string
}

func (*CastNumber) Convert

func (c *CastNumber) Convert(json gjson.Result) (gjson.Result, error)

type Converter

type Converter interface {
	// Convert does transformations on json
	Convert(json gjson.Result) (gjson.Result, error)
}

Converter can do things with rpc params or results

func NewCastNumber

func NewCastNumber(json gjson.Result) (Converter, error)

func NewOverwrite

func NewOverwrite(json gjson.Result) (Converter, error)

func NewRemove

func NewRemove(json gjson.Result) (Converter, error)

func NewRename

func NewRename(json gjson.Result) (Converter, error)

func NewSnakeCase

func NewSnakeCase(json gjson.Result) (Converter, error)

type ConverterFactory

type ConverterFactory func(json gjson.Result) (Converter, error)

ConverterFactory returns instance of specific Converter. Each Converter requires ConverterFactory. ConverterFactory should be added to NewProvider function

type Overwrite

type Overwrite struct {
	Name     string
	NewValue interface{}
}

func (*Overwrite) Convert

func (c *Overwrite) Convert(json gjson.Result) (gjson.Result, error)

type Provider

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

Provider keeps ConverterFactories

func NewProvider

func NewProvider() *Provider

NewProvider returns new Provider with buildin converters

func (*Provider) Add

func (p *Provider) Add(converterType string, factory ConverterFactory)

Add adds ConverterFactory to Provider

func (*Provider) Get

func (p *Provider) Get(converterType string, config gjson.Result) (Converter, error)

Get creates and returns Converter by its type and config

type Remove

type Remove struct {
	Name string
}

func (*Remove) Convert

func (c *Remove) Convert(json gjson.Result) (gjson.Result, error)

type Rename

type Rename struct {
	From string
	To   string
}

func (*Rename) Convert

func (c *Rename) Convert(json gjson.Result) (gjson.Result, error)

Jump to

Keyboard shortcuts

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