Fix GET to http.MethodGet
This commit is contained in:
parent
0206b94abc
commit
b4e56b6ff8
15
accounts.go
15
accounts.go
|
@ -2,6 +2,7 @@ package mastodon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
@ -28,7 +29,7 @@ type Account struct {
|
|||
// GetAccount return Account.
|
||||
func (c *Client) GetAccount(id int) (*Account, error) {
|
||||
var account Account
|
||||
err := c.doAPI("GET", fmt.Sprintf("/api/v1/accounts/%d", id), nil, &account)
|
||||
err := c.doAPI(http.MethodGet, fmt.Sprintf("/api/v1/accounts/%d", id), nil, &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -38,7 +39,7 @@ func (c *Client) GetAccount(id int) (*Account, error) {
|
|||
// GetAccountCurrentUser return Account of current user.
|
||||
func (c *Client) GetAccountCurrentUser() (*Account, error) {
|
||||
var account Account
|
||||
err := c.doAPI("GET", "/api/v1/accounts/verify_credentials", nil, &account)
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/accounts/verify_credentials", nil, &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -48,7 +49,7 @@ func (c *Client) GetAccountCurrentUser() (*Account, error) {
|
|||
// GetAccountFollowers return followers list.
|
||||
func (c *Client) GetAccountFollowers(id int64) ([]*Account, error) {
|
||||
var accounts []*Account
|
||||
err := c.doAPI("GET", fmt.Sprintf("/api/v1/accounts/%d/followers", id), nil, &accounts)
|
||||
err := c.doAPI(http.MethodGet, fmt.Sprintf("/api/v1/accounts/%d/followers", id), nil, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -58,7 +59,7 @@ func (c *Client) GetAccountFollowers(id int64) ([]*Account, error) {
|
|||
// GetAccountFollowing return following list.
|
||||
func (c *Client) GetAccountFollowing(id int64) ([]*Account, error) {
|
||||
var accounts []*Account
|
||||
err := c.doAPI("GET", fmt.Sprintf("/api/v1/accounts/%d/following", id), nil, &accounts)
|
||||
err := c.doAPI(http.MethodGet, fmt.Sprintf("/api/v1/accounts/%d/following", id), nil, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ func (c *Client) GetAccountRelationship(id int64) ([]*Relationship, error) {
|
|||
params.Set("id", fmt.Sprint(id))
|
||||
|
||||
var relationships []*Relationship
|
||||
err := c.doAPI("GET", "/api/v1/accounts/relationship", params, &relationships)
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/accounts/relationship", params, &relationships)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ func (c *Client) AccountsSearch(q string, limit int64) ([]*Account, error) {
|
|||
params.Set("limit", fmt.Sprint(limit))
|
||||
|
||||
var accounts []*Account
|
||||
err := c.doAPI("GET", "/api/v1/accounts/search", params, &accounts)
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/accounts/search", params, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -180,7 +181,7 @@ func (c *Client) GetFollowRequests(uri string) ([]*Account, error) {
|
|||
params.Set("uri", uri)
|
||||
|
||||
var accounts []*Account
|
||||
err := c.doAPI("GET", "/api/v1/follow_requests", params, &accounts)
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/follow_requests", params, &accounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func (c *Client) doAPI(method string, uri string, params url.Values, res interfa
|
|||
return nil
|
||||
}
|
||||
|
||||
if method == "GET" && resp.StatusCode != http.StatusOK {
|
||||
if method == http.MethodGet && resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("bad request: %v", resp.Status)
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ type Status struct {
|
|||
// GetTimelineHome return statuses from home timeline.
|
||||
func (c *Client) GetTimelineHome() ([]*Status, error) {
|
||||
var statuses []*Status
|
||||
err := c.doAPI("GET", "/api/v1/timelines/home", nil, &statuses)
|
||||
err := c.doAPI(http.MethodGet, "/api/v1/timelines/home", nil, &statuses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ func (c *Client) StreamingPublic(ctx context.Context) (chan Event, error) {
|
|||
defer ctx.Done()
|
||||
|
||||
for {
|
||||
req, err := http.NewRequest("GET", url.String(), nil)
|
||||
req, err := http.NewRequest(http.MethodGet, url.String(), nil)
|
||||
if err == nil {
|
||||
req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)
|
||||
resp, err = c.Do(req)
|
||||
|
|
Loading…
Reference in New Issue
Block a user