|
1 |
| -package postman |
2 |
| - |
3 |
| -// ListenType defines the kind of script attached to an event. |
4 |
| -type ListenType string |
5 |
| - |
6 |
| -const ( |
7 |
| - // PreRequest script is usually executed before the HTTP request is sent. |
8 |
| - PreRequest ListenType = "prerequest" |
9 |
| - // Test script is usually executed after the actual HTTP request is sent, and the response is received. |
10 |
| - Test ListenType = "test" |
11 |
| -) |
12 |
| - |
13 |
| -// A Script is a snippet of Javascript code that can be used to to perform setup or teardown operations on a particular response. |
14 |
| -type Script struct { |
15 |
| - ID string `json:"id,omitempty"` |
16 |
| - Type string `json:"type,omitempty"` |
17 |
| - Exec []string `json:"exec,omitempty"` |
18 |
| - Src *URL `json:"src,omitempty"` |
19 |
| - Name string `json:"name,omitempty"` |
20 |
| -} |
21 |
| - |
22 |
| -// An Event defines a script associated with an associated event name. |
23 |
| -type Event struct { |
24 |
| - ID string `json:"id,omitempty"` |
25 |
| - Listen ListenType `json:"listen,omitempty"` |
26 |
| - Script *Script `json:"script,omitempty"` |
27 |
| - Disabled bool `json:"disabled,omitempty"` |
28 |
| -} |
29 |
| - |
30 |
| -// CreateEvent creates a new Event of type text/javascript. |
31 |
| -func CreateEvent(listenType ListenType, script []string) *Event { |
32 |
| - return &Event{ |
33 |
| - Listen: listenType, |
34 |
| - Script: &Script{ |
35 |
| - Type: "text/javascript", |
36 |
| - Exec: script, |
37 |
| - }, |
38 |
| - } |
39 |
| -} |
| 1 | +package postman |
| 2 | + |
| 3 | +// ListenType defines the kind of script attached to an event. |
| 4 | +type ListenType string |
| 5 | + |
| 6 | +const ( |
| 7 | + // PreRequest script is usually executed before the HTTP request is sent. |
| 8 | + PreRequest ListenType = "prerequest" |
| 9 | + // Test script is usually executed after the actual HTTP request is sent, and the response is received. |
| 10 | + Test ListenType = "test" |
| 11 | +) |
| 12 | + |
| 13 | +// A Script is a snippet of Javascript code that can be used to to perform setup or teardown operations on a particular response. |
| 14 | +type Script struct { |
| 15 | + ID string `json:"id,omitempty"` |
| 16 | + Type string `json:"type,omitempty"` |
| 17 | + Exec []string `json:"exec,omitempty"` |
| 18 | + Src *URL `json:"src,omitempty"` |
| 19 | + Name string `json:"name,omitempty"` |
| 20 | +} |
| 21 | + |
| 22 | +// An Event defines a script associated with an associated event name. |
| 23 | +type Event struct { |
| 24 | + ID string `json:"id,omitempty"` |
| 25 | + Listen ListenType `json:"listen,omitempty"` |
| 26 | + Script *Script `json:"script,omitempty"` |
| 27 | + Disabled bool `json:"disabled,omitempty"` |
| 28 | +} |
| 29 | + |
| 30 | +// CreateEvent creates a new Event of type text/javascript. |
| 31 | +func CreateEvent(listenType ListenType, script []string) *Event { |
| 32 | + return &Event{ |
| 33 | + Listen: listenType, |
| 34 | + Script: &Script{ |
| 35 | + Type: "text/javascript", |
| 36 | + Exec: script, |
| 37 | + }, |
| 38 | + } |
| 39 | +} |
0 commit comments