From 61afc65377dc06b5a6ea494fc46881898d760d47 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 28 Nov 2023 10:55:53 +0100 Subject: [PATCH] Implement Get method on Client struct --- modules/activitypub/client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index dc42e14cdf..f95b5e9a7e 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -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)