use NewRequestWithContext
parent
ac5bfa7ad7
commit
ab1da46096
3
main.go
3
main.go
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue