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) - } - } -}