use NewRequestWithContext

master
magical 2021-12-31 22:25:30 +00:00
parent ac5bfa7ad7
commit ab1da46096
2 changed files with 2 additions and 4 deletions

View File

@ -101,13 +101,12 @@ func (src *FeedSource) update(ctx context.Context) {
defer src.mu.Unlock()
fp := gofeed.NewParser()
req, err := http.NewRequest("GET", src.URL, nil)
req, err := http.NewRequestWithContext(ctx, "GET", src.URL, nil)
if err != nil {
src.Error = fmt.Errorf("error fetching %q: %w", src.URL, err)
log.Println(src.Error)
return // return err?
}
req = req.WithContext(ctx)
req.Header.Set("User-Agent", UserAgent)
// TODO: If-Modified-Since, Etag

View File

@ -95,13 +95,12 @@ func (src *MastoSource) update(ctx context.Context) {
src.mu.Lock()
defer src.mu.Unlock()
req, err := http.NewRequest("GET", src.URL, nil)
req, err := http.NewRequestWithContext(ctx, "GET", src.URL, nil)
if err != nil {
src.Error = fmt.Errorf("error fetching %q: %w", src.URL, err)
log.Println(src.Error)
return // return err?
}
req = req.WithContext(ctx)
req.Header.Set("User-Agent", UserAgent)
// TODO: If-Modified-Since, Etag