From 37a6c09dc3673b8a5a8b18f47eb123b46a0bb776 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 17 Jul 2023 16:57:28 +0300 Subject: [PATCH] Remove unused request functions --- libgm/request.go | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/libgm/request.go b/libgm/request.go index b6c4de1..8ce0614 100644 --- a/libgm/request.go +++ b/libgm/request.go @@ -3,42 +3,10 @@ package libgm import ( "bytes" "net/http" - "reflect" "go.mau.fi/mautrix-gmessages/libgm/util" ) -func (c *Client) PostRequest(url string, payload []byte, headers interface{}) (*http.Response, error) { - req, err := http.NewRequest("POST", url, bytes.NewReader(payload)) - if err != nil { - return nil, err - } - reqHeaders := &http.Header{} - SetHeaders(reqHeaders, headers) - req.Header = *reqHeaders - res, reqErr := c.http.Do(req) - if reqErr != nil { - return res, reqErr - } - return res, nil -} - -func (c *Client) GetRequest(url string, headers interface{}) (*http.Response, error) { - req, err := http.NewRequest("GET", url, nil) - - if err != nil { - return nil, err - } - reqHeaders := &http.Header{} - SetHeaders(reqHeaders, headers) - req.Header = *reqHeaders - res, reqErr := c.http.Do(req) - if reqErr != nil { - return res, reqErr - } - return res, nil -} - func (c *Client) MakeRelayRequest(url string, body []byte) (*http.Response, error) { req, err := http.NewRequest("POST", url, bytes.NewReader(body)) if err != nil { @@ -51,17 +19,3 @@ func (c *Client) MakeRelayRequest(url string, body []byte) (*http.Response, erro } return res, nil } - -func SetHeaders(h *http.Header, headers interface{}) { - if headers == nil { - return - } - v := reflect.ValueOf(headers) - for i := 0; i < v.NumField(); i++ { - field := v.Type().Field(i) - value := v.Field(i).String() - if !v.Field(i).IsZero() { - h.Set(field.Tag.Get("header"), value) - } - } -}