msActionWrapper

package
v0.0.0-...-0bff97c Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2017 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(jsonAction []byte) (common.Action, error)

Create creates and returns an initialized Action object that corresponds to the type and holds the data defined to the given JSON-object byte slice.

Types

type ActionFactory

type ActionFactory func(jsonAction *json.RawMessage) (common.Action, error)

ActionFactory is a function type that should be implemented by all Action factories. It defines a function that receives the JSON-encoded Action object (in raw bytes), and it returs the corresponding Action object, including any initializations required such as dependency injection.

type ActionWrapper

type ActionWrapper struct {
	Type   string        `json:"type"`
	Action common.Action `json:"action"`
}

ActionWrapper provides a structure that holds an Action together with its type.

func Wrapper

func Wrapper(action common.Action) (*ActionWrapper, error)

Wrapper creates an ActionWrapper for the given Action, based on its type that is detected via reflection.

func (*ActionWrapper) UnmarshalJSON

func (wrapper *ActionWrapper) UnmarshalJSON(bytes []byte) error

UnmarshalJSON properly decodes an ActionWrapper JSON object by decoding the contained Action depending on the value of the "type" field.

Jump to

Keyboard shortcuts

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