common

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetByteFromTransferable

func GetByteFromTransferable(d Transferable) ([]byte, error)

func PrepareRequestToSend

func PrepareRequestToSend(r *http.Request, domain string) ([]byte, error)

func PrepareRouteCallback

func PrepareRouteCallback(route, callback, command string) ([]byte, error)

func PrepareRouteCallbackInformation

func PrepareRouteCallbackInformation(route, callback string) ([]byte, error)

func PrepareRouteCallbackToSend

func PrepareRouteCallbackToSend(route, callback string) ([]byte, error)

func ReceiveDataFromConnection

func ReceiveDataFromConnection(conn net.Conn) ([]byte, error)

func SendDataToConnection

func SendDataToConnection(conn net.Conn, b []byte) (int, error)

Types

type Header map[string][]string

type Request

type Request struct {
	Method   string `json:"method"`
	Callback string `json:"callback"`
	URL      string `json:"url"`
	Proto    string `json:"protocol"`
	Header   Header `json:"header"`
	Body     []byte `json:"body"`
	Host     string `json:"host"`
}

It's a minified version of http.Request and documentation of fields can be found on corresponded struct

func GetInformationOfRequest

func GetInformationOfRequest(r *http.Request, domain string) *Request

type RouteCallback

type RouteCallback struct {
	Route    string `json:"route"`
	Callback string `json:"callback"`
}

type Transferable

type Transferable interface {
	GetType() string
	GetCommand() string
	GetData() interface{}
}

type TransferableData

type TransferableData struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

func GetTransferableFromByte

func GetTransferableFromByte(d []byte) (*TransferableData, error)

func PrepareReceivedData

func PrepareReceivedData(d []byte) (*TransferableData, error)

func UnmarshalTransferable

func UnmarshalTransferable(t Transferable, b []byte) (*TransferableData, error)

type TransferableError

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

func (*TransferableError) Error

func (e *TransferableError) Error() string

type TransferableRequest

type TransferableRequest struct {
	Command string   `json:"command"`
	Data    *Request `json:"data"`
}

func (*TransferableRequest) GetCommand

func (s *TransferableRequest) GetCommand() string

func (*TransferableRequest) GetData

func (s *TransferableRequest) GetData() interface{}

func (*TransferableRequest) GetType

func (s *TransferableRequest) GetType() string

type TransferableRouteCallback

type TransferableRouteCallback struct {
	Command string         `json:"command"`
	Data    *RouteCallback `json:"data"`
}

func (*TransferableRouteCallback) GetCommand

func (s *TransferableRouteCallback) GetCommand() string

func (*TransferableRouteCallback) GetData

func (s *TransferableRouteCallback) GetData() interface{}

func (*TransferableRouteCallback) GetType

func (s *TransferableRouteCallback) GetType() string

type TransferableString

type TransferableString struct {
	Command string `json:"command"`
	Data    string `json:"data"`
}

func (*TransferableString) GetCommand

func (s *TransferableString) GetCommand() string

func (*TransferableString) GetData

func (s *TransferableString) GetData() interface{}

func (*TransferableString) GetType

func (s *TransferableString) GetType() string

Jump to

Keyboard shortcuts

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