aboutsummaryrefslogtreecommitdiff
path: root/mastodon/mastodon.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2023-10-01 13:04:07 +0000
committerr <r@freesoftwareextremist.com>2023-10-01 13:04:07 +0000
commit81bdc7c705d5d21f62927167d5b2c8e4932c9570 (patch)
tree8bdd670af920ac0541391366b5711462d9df0fab /mastodon/mastodon.go
parent8e3999fc3d9761f9ce71c35a7154a77c251caa66 (diff)
downloadbloat-81bdc7c705d5d21f62927167d5b2c8e4932c9570.tar.gz
bloat-81bdc7c705d5d21f62927167d5b2c8e4932c9570.zip
Add profile edit page
Diffstat (limited to 'mastodon/mastodon.go')
-rw-r--r--mastodon/mastodon.go11
1 files changed, 11 insertions, 0 deletions
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()