interact

package
v0.0.0-...-e9f0680 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: AGPL-3.0 Imports: 18 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 ImposterMockCase

type ImposterMockCase struct {
	Request  Request  `json:"request" yaml:"request"`
	Response Response `json:"response" yaml:"response"`
}

ImposterMockCase define an imposter structure (a mock case)

func GRPCConvert

func GRPCConvert(reqMD metadata.MD, dto ggrpcurl.GGrpCurlDTO,
	respMD metadata.MD, respTrailer metadata.MD,
	respBody string, s *status.Status) *ImposterMockCase

func HttpConverter

func HttpConverter(req *http.Request, resp *http.Response) (*ImposterMockCase, error)

func (*ImposterMockCase) Delay

func (i *ImposterMockCase) Delay() time.Duration

Delay returns delay for response that user can specify in imposter config

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" yaml:"protocol"`
	Method   string              `json:"method" yaml:"method"`
	Host     string              `json:"host" yaml:"host"`
	Path     string              `json:"path" yaml:"path"`
	Header   map[string][]string `json:"header" yaml:"header"`
	Query    map[string][]string `json:"query" yaml:"query"`
	Body     interface{}         `json:"body" yaml:"body"`
}

Request defines the request structure

func (*Request) GetBodyString

func (r *Request) GetBodyString() string

type Response

type Response struct {
	Status  int                 `json:"status" yaml:"status"`
	Header  map[string][]string `json:"header" yaml:"header"`
	Body    interface{}         `json:"body" yaml:"body"`
	Trailer map[string][]string `json:"trailer" yaml:"trailer"`
	Delay   *ResponseDelay      `json:"delay" yaml:"delay"`
}

Response represent the structure of real response

func NewDefaultResponse

func NewDefaultResponse(request *Request) *Response

NewDefaultResponse is used to create default response

func (*Response) GetByteData

func (r *Response) GetByteData() ([]byte, error)

type ResponseDelay

type ResponseDelay struct {
	Delay  int64 `json:"delay" yaml:"delay"`
	Offset int64 `json:"offset" yaml:"offset"`
}

ResponseDelay represent time delay before server responds.

func (*ResponseDelay) GetDelay

func (d *ResponseDelay) GetDelay() time.Duration

GetDelay return random time.Duration with respect to specified time range.

Jump to

Keyboard shortcuts

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