Documentation ¶
Index ¶
- type BytesMessage
- func (b *BytesMessage) Bytes() []byte
- func (b *BytesMessage) Marshal() ([]byte, error)
- func (b *BytesMessage) MarshalJSON() ([]byte, error)
- func (b *BytesMessage) ProtoMessage()
- func (b *BytesMessage) Reset()
- func (b *BytesMessage) String() string
- func (b *BytesMessage) UnmarshalJSON(data []byte) error
- type ImposterMockCase
- type Message
- type Protocol
- type Request
- type Response
- type ResponseDelay
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 HttpConverter ¶
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 ¶
NewBytesMessage is used to init BytesMessage
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 ¶
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 ¶
NewDefaultResponse is used to create default response
func (*Response) GetByteData ¶
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.