-
Notifications
You must be signed in to change notification settings - Fork 204
/
simulation_views_v1.go
118 lines (89 loc) · 4.48 KB
/
simulation_views_v1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package v2
import (
"github.com/SpectoLabs/hoverfly/core/interfaces"
"github.com/SpectoLabs/hoverfly/core/util"
)
type SimulationViewV1 struct {
DataViewV1 `json:"data"`
MetaView `json:"meta"`
}
type DataViewV1 struct {
RequestResponsePairViewV1 []RequestResponsePairViewV1 `json:"pairs"`
GlobalActions GlobalActionsView `json:"globalActions"`
}
type RequestResponsePairViewV1 struct {
Response ResponseDetailsView `json:"response"`
Request RequestDetailsView `json:"request"`
}
// Gets Response - required for interfaces.RequestResponsePairView
func (this RequestResponsePairViewV1) GetResponse() interfaces.Response { return this.Response }
// Gets RequestMatcher - required for interfaces.RequestResponsePairView
func (this RequestResponsePairViewV1) GetRequest() interfaces.Request { return this.Request }
// ResponseDetailsView is used when marshalling and
// unmarshalling requests. This struct's Body may be Base64
// encoded based on the EncodedBody field.
type ResponseDetailsView struct {
Status int `json:"status"`
Body string `json:"body"`
EncodedBody bool `json:"encodedBody"`
Headers map[string][]string `json:"headers,omitempty"`
PostServeAction string `json:"postServeAction,omitempty"`
}
// Gets Status - required for interfaces.Response
func (this ResponseDetailsView) GetStatus() int { return this.Status }
// Gets Body - required for interfaces.Response
func (this ResponseDetailsView) GetBody() string { return this.Body }
// Gets BodyFile - required for interfaces.Response
func (this ResponseDetailsView) GetBodyFile() string { return "" }
// Gets EncodedBody - required for interfaces.Response
func (this ResponseDetailsView) GetEncodedBody() bool { return this.EncodedBody }
func (this RequestDetailsView) GetFormData() map[string][]string { return this.FormData }
func (this ResponseDetailsView) GetTemplated() bool { return false }
func (this ResponseDetailsView) GetTransitionsState() map[string]string { return nil }
func (this ResponseDetailsView) GetRemovesState() []string { return nil }
// Gets Headers - required for interfaces.Response
func (this ResponseDetailsView) GetHeaders() map[string][]string { return this.Headers }
// Gets FixedDelay - required for interfaces.Response
func (this ResponseDetailsView) GetFixedDelay() int { return 0 }
// Gets LogNormalDelay - required for interfaces.Response
func (this ResponseDetailsView) GetLogNormalDelay() interfaces.ResponseDelay { return nil }
func (this ResponseDetailsView) GetPostServeAction() string {
return this.PostServeAction
}
// RequestDetailsView is used when marshalling and unmarshalling RequestDetails
type RequestDetailsView struct {
RequestType *string `json:"requestType,omitempty"`
Path *string `json:"path"`
Method *string `json:"method"`
Destination *string `json:"destination"`
Scheme *string `json:"scheme"`
Query *string `json:"query"`
QueryMap map[string][]string `json:"-"`
FormData map[string][]string `json:"formData"`
Body *string `json:"body"`
Headers map[string][]string `json:"headers"`
}
// Gets Path - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetPath() *string { return this.Path }
// Gets Method - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetMethod() *string { return this.Method }
// Gets Destination - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetDestination() *string { return this.Destination }
// Gets Scheme - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetScheme() *string { return this.Scheme }
// Gets Query - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetQuery() *string {
if this.Query == nil {
return this.Query
}
queryString := util.SortQueryString(*this.Query)
return &queryString
}
// Gets Body - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetBody() *string { return this.Body }
// Gets Headers - required for interfaces.RequestMatcher
func (this RequestDetailsView) GetHeaders() map[string][]string { return this.Headers }
// Gets FixedDelay - required for interfaces.Response
func (this RequestDetailsView) GetFixedDelay() int { return 0 }
// Gets LogNormalDelay - required for interfaces.Response
func (this RequestDetailsView) GetLogNormalDelay() interfaces.ResponseDelay { return nil }