1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Use stdlib HTTP client for third-party integrations

This commit is contained in:
Frédéric Guillot 2023-08-13 21:58:45 -07:00
parent e5d9f2f5a0
commit 5e520ca5bf
34 changed files with 509 additions and 358 deletions

View file

@ -26,7 +26,7 @@ func NewClient(baseURL, username, password string) *Client {
return &Client{baseURL: baseURL, username: username, password: password}
}
func (c *Client) AddBookmark(entryURL, entryTitle string) error {
func (c *Client) CreateBookmark(entryURL, entryTitle string) error {
if c.baseURL == "" || c.username == "" || c.password == "" {
return fmt.Errorf("shiori: missing base URL, username or password")
}
@ -51,13 +51,12 @@ func (c *Client) AddBookmark(entryURL, entryTitle string) error {
return fmt.Errorf("shiori: unable to encode request body: %v", err)
}
request, err := http.NewRequest("POST", apiEndpoint, bytes.NewReader(requestBody))
request, err := http.NewRequest(http.MethodPost, apiEndpoint, bytes.NewReader(requestBody))
if err != nil {
return fmt.Errorf("shiori: unable to create request: %v", err)
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Accept", "application/json")
request.Header.Set("User-Agent", "Miniflux/"+version.Version)
request.Header.Set("X-Session-Id", sessionID)
@ -87,7 +86,7 @@ func (c *Client) authenticate() (sessionID string, err error) {
return "", fmt.Errorf("shiori: unable to encode request body: %v", err)
}
request, err := http.NewRequest("POST", apiEndpoint, bytes.NewReader(requestBody))
request, err := http.NewRequest(http.MethodPost, apiEndpoint, bytes.NewReader(requestBody))
if err != nil {
return "", fmt.Errorf("shiori: unable to create request: %v", err)
}