From 81bdc7c705d5d21f62927167d5b2c8e4932c9570 Mon Sep 17 00:00:00 2001 From: r Date: Sun, 1 Oct 2023 13:04:07 +0000 Subject: Add profile edit page --- mastodon/mastodon.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mastodon/mastodon.go') diff --git a/mastodon/mastodon.go b/mastodon/mastodon.go index f114169..94e2cf5 100644 --- a/mastodon/mastodon.go +++ b/mastodon/mastodon.go @@ -33,6 +33,11 @@ type Client struct { config *Config } +type multipartRequest struct { + Data io.Reader + ContentType string +} + func (c *Client) doAPI(ctx context.Context, method string, uri string, params interface{}, res interface{}, pg *Pagination) error { u, err := url.Parse(c.config.Server) if err != nil { @@ -133,6 +138,12 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in return err } ct = mw.FormDataContentType() + } else if mr, ok := params.(*multipartRequest); ok { + req, err = http.NewRequest(method, u.String(), mr.Data) + if err != nil { + return err + } + ct = mr.ContentType } else { if method == http.MethodGet && pg != nil { u.RawQuery = pg.toValues().Encode() -- cgit v1.2.3