@@ -22,11 +22,16 @@ func Get(
2222 url , address string ,
2323 timeout time.Duration ,
2424 headers , queryParams map [string ]string ,
25- logging bool ,
25+ opts ... Option ,
2626) (int , string , error ) {
27- resp , err := makeRequest (http .MethodGet , url , address , nil , timeout , headers , queryParams , logging )
27+ options := & Options {logEnabled : true }
28+ for _ , opt := range opts {
29+ opt (options )
30+ }
31+
32+ resp , err := makeRequest (http .MethodGet , url , address , nil , timeout , headers , queryParams , opts ... )
2833 if err != nil {
29- if logging {
34+ if options . logEnabled {
3035 GinkgoWriter .Printf (
3136 "ERROR occurred during getting response, error: %s\n Returning status: 0, body: ''\n " ,
3237 err ,
@@ -43,7 +48,7 @@ func Get(
4348 GinkgoWriter .Printf ("ERROR in Body content: %v returning body: ''\n " , err )
4449 return resp .StatusCode , "" , err
4550 }
46- if logging {
51+ if options . logEnabled {
4752 GinkgoWriter .Printf ("Successfully received response and parsed body: %s\n " , body .String ())
4853 }
4954
@@ -58,7 +63,7 @@ func Post(
5863 timeout time.Duration ,
5964 headers , queryParams map [string ]string ,
6065) (* http.Response , error ) {
61- response , err := makeRequest (http .MethodPost , url , address , body , timeout , headers , queryParams , true )
66+ response , err := makeRequest (http .MethodPost , url , address , body , timeout , headers , queryParams )
6267 if err != nil {
6368 GinkgoWriter .Printf ("ERROR occurred during getting response, error: %s\n " , err )
6469 }
@@ -71,7 +76,7 @@ func makeRequest(
7176 body io.Reader ,
7277 timeout time.Duration ,
7378 headers , queryParams map [string ]string ,
74- logging bool ,
79+ opts ... Option ,
7580) (* http.Response , error ) {
7681 dialer := & net.Dialer {}
7782
@@ -94,7 +99,12 @@ func makeRequest(
9499 ctx , cancel := context .WithTimeout (context .Background (), timeout )
95100 defer cancel ()
96101
97- if logging {
102+ options := & Options {logEnabled : true }
103+
104+ for _ , opt := range opts {
105+ opt (options )
106+ }
107+ if options .logEnabled {
98108 requestDetails := fmt .Sprintf (
99109 "Method: %s, URL: %s, Address: %s, Headers: %v, QueryParams: %v\n " ,
100110 strings .ToUpper (method ),
0 commit comments