Documentation
¶
Index ¶
Constants ¶
View Source
const Wildcard = ".*"
Variables ¶
View Source
var NotFound = Rule{ Name: "no_match", Response: Response{ StatusCode: http.StatusNotImplemented, BodyString: "no response for request", }, }
NotFound is used when nothing matches. A 5xx is returned as a 404 would be easier to confuse with a normal prepared response.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
A Handler handles stubbed calls.
type Persistence ¶
type Response ¶
type Response struct { // Response status code StatusCode int `json:"statusCode"` // Response body string. Only one body field can be used. BodyString string `json:"bodyString"` // Response body JSON. Only one body field can be used BodyJSON any `json:"bodyJson"` // Response headers Headers map[string][]string `json:"headers"` }
type Rule ¶
type Rule struct { // The name of the rule. Name string `json:"name"` // A description, no functional impact. Description string `json:"description"` // HTTP method to match. Method string `json:"method"` // Path to match. Path string `json:"path"` // Path regex to match. PathRegex string `json:"pathRegex"` // Request query parameters. An entry with a zero-length value list will // only check for presence of the key. Params map[string][]string `json:"params"` // TODO(hvl): matching // Request headers. An entry with a zero-length value list will only check // for presence of the key. Headers map[string][]string `json:"headers"` // Request body to match as a string. BodyString string `json:"bodyString"` // Regex of body to match as a string. BodyStringRegex string `json:"bodyStringRegex"` // The JSON body to match. Field values can be a Wildcard. BodyJSON any `json:"body"` // The response to return. Response Response `json:"response"` // contains filtered or unexported fields }
func RuleFromRequest ¶
func (Rule) EqualMatch ¶
Click to show internal directories.
Click to hide internal directories.