convey

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(parent context.Context, v C) context.Context

func WriteBytes

func WriteBytes(t Translator, v C) ([]byte, error)

WriteBytes uses the given Translator to turn a C into a byte slice

func WriteString

func WriteString(t Translator, v C) (string, error)

WriteString uses the given Translator to turn a C into a string

Types

type C

type C map[string]interface{}

C represents an arbitrary block of JSON which base64-encoded and typically transmitted as an HTTP header. Access should normally be done through an instance of Interface, which this type implements.

func FromContext

func FromContext(ctx context.Context) (C, bool)

func ReadBytes

func ReadBytes(t Translator, v []byte) (C, error)

ReadBytes is like ReadString, but with a byte slice

func ReadString

func ReadString(t Translator, v string) (C, error)

ReadString uses the supplied Translator to extract a C instance from an arbitrary string

func (C) Get

func (c C) Get(key string) (interface{}, bool)

func (C) GetString

func (c C) GetString(key string) (string, bool)

type Compliance

type Compliance int
const (
	Full Compliance = iota
	Missing
	Invalid

	MissingFields
)

func GetCompliance

func GetCompliance(err error) Compliance

GetCompliance examines an error for Compliance information.

If err is nil, Full is returned
If err implements Comply, the result of the Compliance method is returne
Otherwise, Invalid is returned

func (Compliance) String

func (c Compliance) String() string

type Comply

type Comply interface {
	Compliance() Compliance
}

type Error

type Error struct {
	Err error
	C   Compliance
}

func (Error) Compliance

func (e Error) Compliance() Compliance

func (Error) Error

func (e Error) Error() string

type Interface

type Interface interface {
	wrpmeta.Source

	// Get retrieves the raw value for a key, returning false if no such key exists
	Get(key string) (interface{}, bool)
}

Interface represents a read-only view of a convey, and is the standard way to access convey information.

type Translator

type Translator interface {
	// ReadFrom extracts base64-encoded JSON from the supplied reader and produces a convey map.
	// Any error in either base64 decoding or JSON unmarshaling results in an error.
	ReadFrom(io.Reader) (C, error)

	// WriteTo encodes the given convey map into its on-the-wire repesentation, which is base64-encoded
	// JSON.  Any error in either base64 encoding or JSON marhsaling results in an error.
	WriteTo(io.Writer, C) error
}

Translator provides translation between the on-the-wire representation of a convey map and its runtime representation. Instances of Translator are safe for concurrent usage.

func NewTranslator

func NewTranslator(encoding *base64.Encoding) Translator

NewTranslator produces a Translator which uses the specified base64 encoding. If the encoding is nil, base64.StdEncoding is used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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