File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ type Request struct {
32
32
StatusCode int
33
33
}
34
34
35
+ var DatabaseHistory []Request
36
+
35
37
func Builder (method string ) * Request {
36
38
r := Request {}
37
39
@@ -71,8 +73,25 @@ func (r *Request) SetStatusCode(statusCode int) *Request {
71
73
return r
72
74
}
73
75
76
+ // list history of requests, can pass limit
77
+ func GetHistory (limit int ) []Request {
78
+
79
+ if limit == 0 {
80
+ return DatabaseHistory
81
+ }
82
+
83
+ if limit > len (DatabaseHistory ) {
84
+ for i := 0 ; i < len (DatabaseHistory ); i ++ {
85
+ return DatabaseHistory
86
+ }
87
+ }
88
+ return DatabaseHistory [:limit ]
89
+ }
90
+
74
91
func (r * Request ) Execute () ([]byte , error ) {
75
92
93
+ DatabaseHistory = append (DatabaseHistory , * r )
94
+
76
95
client := & http.Client {}
77
96
ctx := context .Background ()
78
97
ctx , cancel := context .WithTimeout (ctx , time .Duration (r .TimeOut )* time .Second )
You can’t perform that action at this time.
0 commit comments