From d6c3570ae7a2ea1b94aa5a0e0d05b16e698f4ef7 Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Sun, 26 Feb 2023 02:24:18 -0500 Subject: [PATCH] clarified function POST and PUT usage with io.Reader --- helper.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helper.go b/helper.go index b6137ca..3317c75 100644 --- a/helper.go +++ b/helper.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" ) @@ -36,7 +37,7 @@ func Get(uri string, authName string, authValue string, queries map[string]strin return response, nil } -func Post(uri string, authName string, authValue string, data any) (*http.Response, error) { +func Post(uri string, authName string, authValue string, data io.Reader) (*http.Response, error) { jsonBytes, err := json.Marshal(data) if err != nil { return nil, err @@ -61,7 +62,7 @@ func Post(uri string, authName string, authValue string, data any) (*http.Respon return response, nil } -func Put(uri string, authName string, authValue string, data any) (*http.Response, error) { +func Put(uri string, authName string, authValue string, data io.Reader) (*http.Response, error) { jsonBytes, err := json.Marshal(data) if err != nil { return nil, err