interact

package
Version: v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesMessage

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

BytesMessage is the simple implement of Message

func (*BytesMessage) Bytes

func (b *BytesMessage) Bytes() []byte

Bytes is used to return native data

func (*BytesMessage) Marshal

func (b *BytesMessage) Marshal() ([]byte, error)

Marshal implements the proto.Marshaler interface

func (*BytesMessage) MarshalJSON

func (b *BytesMessage) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*BytesMessage) ProtoMessage

func (b *BytesMessage) ProtoMessage()

ProtoMessage implements the proto.Message interface

func (*BytesMessage) Reset

func (b *BytesMessage) Reset()

Reset implements the proto.Message interface

func (*BytesMessage) String

func (b *BytesMessage) String() string

String implements the proto.Message interface

func (*BytesMessage) UnmarshalJSON

func (b *BytesMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.UnmarshalJSON interface

type Message

type Message interface {
	proto.Message
	json.Marshaler
	json.Unmarshaler
	proto.Marshaler
	Bytes() []byte
}

Message defines a generic message interface

func NewBytesMessage

func NewBytesMessage(data []byte) Message

NewBytesMessage is used to init BytesMessage

type Protocol

type Protocol string

Protocol defines the protocol of request

const (
	ProtocolHTTP Protocol = "HTTP"
	ProtocolGRPC Protocol = "GRPC"
)

defines a set of known protocols

type Request

type Request struct {
	Protocol Protocol          `json:"protocol"`
	Method   string            `json:"method"`
	Host     string            `json:"host"`
	Path     string            `json:"path"`
	Header   map[string]string `json:"header"`
	Body     Message           `json:"body"`
}

Request defines the request structure

type Response

type Response struct {
	Code    uint32            `json:"code"`
	Header  map[string]string `json:"header"`
	Body    Message           `json:"body"`
	Trailer map[string]string `json:"trailer"`
}

Response defines the response structure

func NewDefaultResponse

func NewDefaultResponse(request *Request) *Response

NewDefaultResponse is used to create default response

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL