Implement Get method on Client struct

This commit is contained in:
erik 2023-11-28 10:55:53 +01:00 committed by Michael Jerger
parent 56d11bbff4
commit 61afc65377

View file

@ -117,7 +117,17 @@ func (c *Client) NewRequest(method string, b []byte, to string) (req *http.Reque
// Post function
func (c *Client) Post(b []byte, to string) (resp *http.Response, err error) {
var req *http.Request
if req, err = c.NewRequest(b, to); err != nil {
if req, err = c.NewRequest(http.MethodPost, b, to); err != nil {
return nil, err
}
resp, err = c.client.Do(req)
return resp, err
}
// Create an http GET request with forgejo/gitea specific headers
func (c *Client) Get(b []byte, to string) (resp *http.Response, err error) {
var req *http.Request
if req, err = c.NewRequest(http.MethodGet, b, to); err != nil {
return nil, err
}
resp, err = c.client.Do(req)