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

Add Notion integration

This commit is contained in:
Jean Khawand 2023-07-08 00:20:14 +02:00 committed by GitHub
parent 06c37a132f
commit bfb4fc1c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 229 additions and 6 deletions

View file

@ -44,9 +44,9 @@ type Client struct {
requestPassword string
requestUserAgent string
requestCookie string
useProxy bool
doNotFollowRedirects bool
customHeaders map[string]string
useProxy bool
doNotFollowRedirects bool
ClientTimeout int
ClientMaxBodySize int64
@ -111,6 +111,12 @@ func (c *Client) WithAuthorization(authorization string) *Client {
return c
}
// WithCustomHeaders defines custom HTTP headers.
func (c *Client) WithCustomHeaders(customHeaders map[string]string) *Client {
c.customHeaders = customHeaders
return c
}
// WithCacheHeaders defines caching headers.
func (c *Client) WithCacheHeaders(etagHeader, lastModifiedHeader string) *Client {
c.requestEtagHeader = etagHeader
@ -183,6 +189,22 @@ func (c *Client) PostJSON(data interface{}) (*Response, error) {
return c.executeRequest(request)
}
// PatchJSON performs a Patch HTTP request with a JSON payload.
func (c *Client) PatchJSON(data interface{}) (*Response, error) {
b, err := json.Marshal(data)
if err != nil {
return nil, err
}
request, err := c.buildRequest(http.MethodPatch, bytes.NewReader(b))
if err != nil {
return nil, err
}
request.Header.Add("Content-Type", "application/json")
return c.executeRequest(request)
}
func (c *Client) executeRequest(request *http.Request) (*Response, error) {
defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[HttpClient] inputURL=%s", c.inputURL))
@ -337,6 +359,10 @@ func (c *Client) buildHeaders() http.Header {
headers.Add("Cookie", c.requestCookie)
}
for key, value := range c.customHeaders {
headers.Add(key, value)
}
headers.Add("Connection", "close")
return headers
}