Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockRequestSimple ¶
MockRequestSimple mocks a HTTP request by sending a command to the HTTP mock server. It only configures the request path, the response status code and the response body. The "application/json" content type is applied implicitly to the response.
Types ¶
type MockRequest ¶
type MockRequest struct { // Permanent is true if the configuration is permanent. // If permanent is false, the mockRequest is removed after matching the first request. Permanent bool `json:"permanent"` Request Request `json:"request"` Response Response `json:"response"` // Latency is the duration in milliseconds to wait to deliver the response. // If 0, there is no latency to apply. // If negative, there will be no response (timeout simulation). Latency int `json:"latency"` }
MockRequest contains the instruction to configure the behavior of the HTTP mock server. The document configures which request is going to be attended (e.g. the path and method) and the response to be generated by the mock.
func (MockRequest) String ¶
func (m MockRequest) String() string
type MockRequests ¶
type MockRequests struct {
// contains filtered or unexported fields
}
func (*MockRequests) CleanMockRequests ¶
func (m *MockRequests) CleanMockRequests()
CleanMockRequests removes all the mockRequests from the list.
func (*MockRequests) MatchMockRequest ¶
func (m *MockRequests) MatchMockRequest(r *http.Request) *MockRequest
MatchMockRequest finds the first mockRequest matching the HTTP request.
func (*MockRequests) PushMockRequest ¶
func (m *MockRequests) PushMockRequest(mockRequest *MockRequest)
PushMockRequest adds a MockRequest to the list.
func (*MockRequests) RemoveMockRequest ¶
func (m *MockRequests) RemoveMockRequest(mockRequest *MockRequest) bool
Remove a mockRequest. It returns true if it was found and removed.
type Request ¶
type Request struct { Method string `json:"method,omitempty"` Path string `json:"path,omitempty"` Headers map[string][]string `json:"headers,omitempty"` }
Request configures the filter for the request of the MockRequest.
type Response ¶
type Response struct { Status int `json:"status"` Headers map[string][]string `json:"headers"` Body string `json:"body"` }
Response configures which response if the request filter applies.