Documentation
¶
Overview ¶
Package catalog is the list of requests DriftGate sends: one entry is one request, and variants of a route are separate entries with their own ID.
Index ¶
Constants ¶
const MaxRepeat = 10000
MaxRepeat bounds repeat: a catalog entry is a check, not a load test.
const Version = 1
Variables ¶
This section is empty.
Functions ¶
func CheckPath ¶
CheckPath refuses a request or route path that does not start with "/". The path is appended to the base URL, so "@host/x" or ".example.com/x" would send the request, with the identity's token, to another host.
func MutatesFor ¶
MutatesFor is the mutates field a new entry gets from its method: true for one that is not safe, unset otherwise.
func SafeMethod ¶
SafeMethod reports a method that only reads: GET, HEAD, OPTIONS, or none (which is sent as GET).
Types ¶
type Catalog ¶
type Catalog struct {
Version int `json:"version"`
Requests []Request `json:"requests"`
Sequences []Sequence `json:"sequences,omitempty"`
}
Catalog is driftgate/catalog.json.
type File ¶
type File struct {
Field string `json:"field"`
Path string `json:"path,omitempty"`
Ref string `json:"ref,omitempty"` // keyed hash of the content (as a private body is named); a changed file is a configuration change
Synthetic string `json:"synthetic,omitempty"`
Name string `json:"name,omitempty"` // file name sent; default the base name of path, or upload.<ext>
Type string `json:"type,omitempty"` // content type of the part; default from the kind or the extension
}
File is one file of a multipart body: a real file from the uploads folder outside the repository, named by its path relative to that folder and checked by Ref, or a synthetic file of a kind (upload.Kinds). The content never enters the catalog.
type From ¶
type From struct {
Request string `json:"request"`
Path string `json:"path"` // JSON path, e.g. $.entry.id or $.entries[0].id
}
From names a value in the body of another request's response.
type Multipart ¶
type Multipart struct {
Fields [][2]string `json:"fields,omitempty"`
Files []File `json:"files,omitempty"`
}
Multipart is a multipart/form-data body: form fields in order, then files.
type Request ¶
type Request struct {
ID string `json:"id"`
Target string `json:"target,omitempty"` // the service, with several targets
Method string `json:"method"`
Path string `json:"path"`
Params map[string]string `json:"params,omitempty"`
// ParamsFrom takes parameter values from the response of an earlier
// request of the same capture.
ParamsFrom map[string]From `json:"params_from,omitempty"`
Headers [][2]string `json:"headers,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
Identity string `json:"identity,omitempty"`
// Mutates says whether the request changes data; unset, a method other
// than GET, HEAD and OPTIONS does (see Mutating). A search sent as POST
// is written mutates: false.
Mutates *bool `json:"mutates,omitempty"`
Storage string `json:"storage"`
Level string `json:"level,omitempty"`
Observe bool `json:"observe,omitempty"`
Source *Source `json:"source,omitempty"`
// A multipart body with files, sending N times, a command step.
Multipart *Multipart `json:"multipart,omitempty"`
Repeat int `json:"repeat,omitempty"`
Command []string `json:"command,omitempty"`
Output bool `json:"output,omitempty"`
OutputIgnore []string `json:"output_ignore,omitempty"`
}
Request is one catalog entry.
func (Request) IsCommand ¶
IsCommand reports an entry that runs a command instead of sending a request.
func (Request) Mutating ¶
Mutating reports a request that changes data: mutates as written, else any method that is not safe. A request that changes data runs after a restore, one at a time, and needs a state with a restore command.
func (Request) MutatingByMethod ¶
MutatingByMethod reports a request that changes data only because of its method: the catalog does not say mutates. A search sent as POST is one until it is written mutates: false.
func (Request) Sequential ¶
Sequential reports an entry that runs one at a time after the read-only requests, like a request that changes data: a command, a request sent several times (its counters live in the state), or one that uploads a real file (its content may stay in the data, so every response after it until the next restore is stored as private, which only the sequential phase does).