diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-04-28 10:51:07 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-04-28 10:51:07 -0700 |
commit | 1eba1730d1af50ed545f4fde78b22d6fb62ca11e (patch) | |
tree | 61f99282f66529b42625a8f335593bdcb461459c /integration | |
parent | 04adf5fdf53951f270923c41171a52575db53e46 (diff) |
Move HTTP client to its own package
Diffstat (limited to 'integration')
-rw-r--r-- | integration/instapaper/instapaper.go | 7 | ||||
-rw-r--r-- | integration/nunuxkeeper/nunuxkeeper.go | 8 | ||||
-rw-r--r-- | integration/pinboard/pinboard.go | 6 | ||||
-rw-r--r-- | integration/wallabag/wallabag.go | 11 |
4 files changed, 18 insertions, 14 deletions
diff --git a/integration/instapaper/instapaper.go b/integration/instapaper/instapaper.go index 33a2535..52d8ee1 100644 --- a/integration/instapaper/instapaper.go +++ b/integration/instapaper/instapaper.go @@ -8,7 +8,7 @@ import ( "fmt" "net/url" - "github.com/miniflux/miniflux/http" + "github.com/miniflux/miniflux/http/client" ) // Client represents an Instapaper client. @@ -24,8 +24,9 @@ func (c *Client) AddURL(link, title string) error { values.Add("title", title) apiURL := "https://www.instapaper.com/api/add?" + values.Encode() - client := http.NewClientWithCredentials(apiURL, c.username, c.password) - response, err := client.Get() + clt := client.New(apiURL) + clt.WithCredentials(c.username, c.password) + response, err := clt.Get() if response.HasServerFailure() { return fmt.Errorf("instapaper: unable to send url, status=%d", response.StatusCode) } diff --git a/integration/nunuxkeeper/nunuxkeeper.go b/integration/nunuxkeeper/nunuxkeeper.go index 4627e8d..4ea5c45 100644 --- a/integration/nunuxkeeper/nunuxkeeper.go +++ b/integration/nunuxkeeper/nunuxkeeper.go @@ -9,7 +9,7 @@ import ( "net/url" "path" - "github.com/miniflux/miniflux/http" + "github.com/miniflux/miniflux/http/client" ) // Document structure of a Nununx Keeper document @@ -39,8 +39,10 @@ func (c *Client) AddEntry(link, title, content string) error { if err != nil { return err } - client := http.NewClientWithCredentials(apiURL, "api", c.apiKey) - response, err := client.PostJSON(doc) + + clt := client.New(apiURL) + clt.WithCredentials("api", c.apiKey) + response, err := clt.PostJSON(doc) if response.HasServerFailure() { return fmt.Errorf("nunux-keeper: unable to send entry, status=%d", response.StatusCode) } diff --git a/integration/pinboard/pinboard.go b/integration/pinboard/pinboard.go index bad65b1..54294ae 100644 --- a/integration/pinboard/pinboard.go +++ b/integration/pinboard/pinboard.go @@ -8,7 +8,7 @@ import ( "fmt" "net/url" - "github.com/miniflux/miniflux/http" + "github.com/miniflux/miniflux/http/client" ) // Client represents a Pinboard client. @@ -30,8 +30,8 @@ func (c *Client) AddBookmark(link, title, tags string, markAsUnread bool) error values.Add("tags", tags) values.Add("toread", toRead) - client := http.NewClient("https://api.pinboard.in/v1/posts/add?" + values.Encode()) - response, err := client.Get() + clt := client.New("https://api.pinboard.in/v1/posts/add?" + values.Encode()) + response, err := clt.Get() if response.HasServerFailure() { return fmt.Errorf("pinboard: unable to send bookmark, status=%d", response.StatusCode) } diff --git a/integration/wallabag/wallabag.go b/integration/wallabag/wallabag.go index fbb100a..58d9c5b 100644 --- a/integration/wallabag/wallabag.go +++ b/integration/wallabag/wallabag.go @@ -10,7 +10,7 @@ import ( "io" "net/url" - "github.com/miniflux/miniflux/http" + "github.com/miniflux/miniflux/http/client" ) // Client represents a Wallabag client. @@ -38,8 +38,9 @@ func (c *Client) createEntry(accessToken, link, title string) error { return fmt.Errorf("wallbag: unable to get entries endpoint: %v", err) } - client := http.NewClientWithAuthorization(endpoint, "Bearer "+accessToken) - response, err := client.PostJSON(map[string]string{"url": link, "title": title}) + clt := client.New(endpoint) + clt.WithAuthorization("Bearer " + accessToken) + response, err := clt.PostJSON(map[string]string{"url": link, "title": title}) if err != nil { return fmt.Errorf("wallabag: unable to post entry: %v", err) } @@ -64,8 +65,8 @@ func (c *Client) getAccessToken() (string, error) { return "", fmt.Errorf("wallbag: unable to get token endpoint: %v", err) } - client := http.NewClient(endpoint) - response, err := client.PostForm(values) + clt := client.New(endpoint) + response, err := clt.PostForm(values) if err != nil { return "", fmt.Errorf("wallabag: unable to get access token: %v", err) } |