Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(mux httpMux, endpoints []*Endpoint)
RegisterHandlers registers endpoint handlers to the given HTTP mux.
Types ¶
type Endpoint ¶
func NewEndpoint ¶
func NewEndpoint(path, method string, respResolver ResponseResolver) *Endpoint
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(opts ...ResponseOption) (Response, error)
type ResponseOption ¶
func WithResponseBody ¶
func WithResponseBody(body []byte) ResponseOption
func WithResponseDelay ¶
func WithResponseDelay(delay time.Duration) ResponseOption
func WithResponseHeaders ¶
func WithResponseHeaders(headers map[string]string) ResponseOption
func WithResponseStatus ¶
func WithResponseStatus(statusCode int) ResponseOption
type ResponseResolver ¶
type ResponseResolver interface {
NextResponse() Response
}
type SequenceBehavior ¶
type SequenceBehavior string
const ( SequenceBehaviorLoop SequenceBehavior = "loop" SequenceBehaviorRepeatLast SequenceBehavior = "repeatLast" )
type SequencedResponse ¶
type SequencedResponse struct {
// contains filtered or unexported fields
}
func NewSequencedResponse ¶
func NewSequencedResponse(endBehavior SequenceBehavior, sequence []Response) (*SequencedResponse, error)
func (*SequencedResponse) NextResponse ¶
func (s *SequencedResponse) NextResponse() Response
type StaticResponse ¶
type StaticResponse Response
func (StaticResponse) NextResponse ¶
func (r StaticResponse) NextResponse() Response
type WeightedResponse ¶
type WeightedResponse struct {
// contains filtered or unexported fields
}
func NewWeightedResponse ¶
func NewWeightedResponse(entries []WeightedResponseEntry, numGenerator numberGenerator) (*WeightedResponse, error)
NewWeightedResponse builds a weighted response strategy from the given responses. If numGenerator is nil, a random source is used.
func (*WeightedResponse) NextResponse ¶
func (w *WeightedResponse) NextResponse() Response
type WeightedResponseEntry ¶
Click to show internal directories.
Click to hide internal directories.