diff --git a/accounts.go b/accounts.go index b7da163..2e803ea 100644 --- a/accounts.go +++ b/accounts.go @@ -78,7 +78,7 @@ type Relationship struct { // AccountFollow follow the account. func (c *Client) AccountFollow(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/follow", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/follow", id), nil, &relationship) if err != nil { return nil, err } @@ -88,7 +88,7 @@ func (c *Client) AccountFollow(id int64) (*Relationship, error) { // AccountUnfollow unfollow the account. func (c *Client) AccountUnfollow(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/unfollow", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unfollow", id), nil, &relationship) if err != nil { return nil, err } @@ -98,7 +98,7 @@ func (c *Client) AccountUnfollow(id int64) (*Relationship, error) { // AccountBlock block the account. func (c *Client) AccountBlock(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/block", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/block", id), nil, &relationship) if err != nil { return nil, err } @@ -108,7 +108,7 @@ func (c *Client) AccountBlock(id int64) (*Relationship, error) { // AccountUnblock unblock the account. func (c *Client) AccountUnblock(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/unblock", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unblock", id), nil, &relationship) if err != nil { return nil, err } @@ -118,7 +118,7 @@ func (c *Client) AccountUnblock(id int64) (*Relationship, error) { // AccountMute mute the account. func (c *Client) AccountMute(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/mute", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/mute", id), nil, &relationship) if err != nil { return nil, err } @@ -128,7 +128,7 @@ func (c *Client) AccountMute(id int64) (*Relationship, error) { // AccountUnmute unmute the account. func (c *Client) AccountUnmute(id int64) (*Relationship, error) { var relationship Relationship - err := c.doAPI("POST", fmt.Sprintf("/api/v1/accounts/%d/unmute", id), nil, &relationship) + err := c.doAPI(http.MethodPost, fmt.Sprintf("/api/v1/accounts/%d/unmute", id), nil, &relationship) if err != nil { return nil, err } @@ -168,7 +168,7 @@ func (c *Client) Follow(uri string) (*Account, error) { params.Set("uri", uri) var account Account - err := c.doAPI("POST", "/api/v1/follows", params, &account) + err := c.doAPI(http.MethodPost, "/api/v1/follows", params, &account) if err != nil { return nil, err } diff --git a/apps.go b/apps.go index d51b36e..b5a66d2 100644 --- a/apps.go +++ b/apps.go @@ -51,7 +51,7 @@ func RegisterApp(appConfig *AppConfig) (*Application, error) { } url.Path = path.Join(url.Path, "/api/v1/apps") - req, err := http.NewRequest("POST", url.String(), strings.NewReader(params.Encode())) + req, err := http.NewRequest(http.MethodPost, url.String(), strings.NewReader(params.Encode())) if err != nil { return nil, err } diff --git a/mastodon.go b/mastodon.go index 1112884..cecc2f6 100644 --- a/mastodon.go +++ b/mastodon.go @@ -77,7 +77,7 @@ func (c *Client) Authenticate(username, password string) error { } url.Path = path.Join(url.Path, "/oauth/token") - req, err := http.NewRequest("POST", url.String(), strings.NewReader(params.Encode())) + req, err := http.NewRequest(http.MethodPost, url.String(), strings.NewReader(params.Encode())) if err != nil { return err } @@ -158,7 +158,7 @@ func (c *Client) PostStatus(toot *Toot) (*Status, error) { //params.Set("visibility", "public") var status Status - err := c.doAPI("POST", "/api/v1/statuses", params, &status) + err := c.doAPI(http.MethodPost, "/api/v1/statuses", params, &status) if err != nil { return nil, err } diff --git a/mastodon_test.go b/mastodon_test.go index 6b2a570..bc020f2 100644 --- a/mastodon_test.go +++ b/mastodon_test.go @@ -195,7 +195,7 @@ func TestGetAccountFollowing(t *testing.T) { func TestRegisterApp(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { + if r.Method != http.MethodPost { http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return }