codec

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(d []byte, v interface{}) error

Types

type File

type File struct {
	Name     string `json:"name,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
	Size     int64  `json:"size,omitempty"`
	Data     []byte `json:"data,omitempty"`
}

type Message

type Message struct {
	//HTTP request mandatory fields
	Method string `json:"method,omitempty"`
	Path   string `json:"path,omitempty"`
	Host   string `json:"host,omitempty"`
	Scheme string `json:"scheme,omitempty"`

	//Internal request fields
	ReplyTo   string `json:"replyTo,omitempty"`
	Node      string `json:"node,omitempty"`
	ContextID string `json:"contextID,omitempty"`

	//Internal response fields
	StatusCode int `json:"statusCode,omitempty"`

	//Common fields
	Type    string                 `json:"type,omitempty"`
	Header  http.Header            `json:"header,omitempty"`
	RawBody []byte                 `json:"rawBody,omitempty"`
	Body    map[string]interface{} `json:"body,omitempty"`
}

func NewFileMessage

func NewFileMessage(contextID string) *Message

func NewJsonResponse

func NewJsonResponse(contextID string, statusCode int) *Message

func NewMessage

func NewMessage(t string) *Message

func NewOrderStatusMessage

func NewOrderStatusMessage(origin, user string) *Message

func NewResponse

func NewResponse(contextID string, statusCode int) *Message

NewResponse creates Response Message object.

func (*Message) Del

func (msg *Message) Del(key string)

func (*Message) Get

func (msg *Message) Get(key string) (value interface{}, ok bool)

func (*Message) GetBodyBytes

func (msg *Message) GetBodyBytes() (value []byte)

func (*Message) GetBool

func (msg *Message) GetBool(key string) (value bool, ok bool)

func (*Message) GetBytes

func (msg *Message) GetBytes(key string) (value []byte, ok bool)

func (*Message) GetFloat

func (msg *Message) GetFloat(key string) (value float64, ok bool)

func (*Message) GetInt

func (msg *Message) GetInt(key string) (value int64, ok bool)

func (*Message) GetObjectID

func (msg *Message) GetObjectID(key string) (value bson.ObjectId, ok bool)

func (*Message) GetOrigin

func (msg *Message) GetOrigin() string

func (*Message) GetString

func (msg *Message) GetString(key string) (value string, ok bool)

func (*Message) GetUser

func (msg *Message) GetUser() bson.ObjectId

func (*Message) HasOrigin

func (msg *Message) HasOrigin() bool

func (*Message) HasUser

func (msg *Message) HasUser() bool

func (*Message) OriginContains

func (msg *Message) OriginContains(s string) bool

func (*Message) ParseHTTPRequest

func (msg *Message) ParseHTTPRequest(r *http.Request, replyTo string, contextID string, jsonBody map[string]interface{}) (*Message, error)

func (*Message) Set

func (msg *Message) Set(key string, value interface{})

func (*Message) WriteHTTPResponse

func (msg *Message) WriteHTTPResponse(rw http.ResponseWriter, response *Message)

Jump to

Keyboard shortcuts

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