func (feed *Feed) Fetch() error { var err error logger.Info("Started fetching feed: %s", feed.Url) rss.CacheParsedItemIDs(false) feed.RawData, err = rss.Fetch(feed.Url) if err != nil { return err } logger.Info("Finished fetching feed: %s", feed.Url) logger.Info("There are %d items in %s", len(feed.RawData.Items), feed.Url) return nil }
func FetchFeeds(writer http.ResponseWriter, request *http.Request) { rss.CacheParsedItemIDs(false) feeds, err := db.GetAll() if err != nil { writer.WriteHeader(http.StatusInternalServerError) } if len(feeds) == 0 { return } responses := asyncFetchFeeds(feeds) result := []*rss.Feed{} for _, r := range responses { result = append(result, r.feed) } jsonResult, _ := json.Marshal(result) fmt.Fprintf(writer, string(jsonResult)) }
func init() { rss.CacheParsedItemIDs(false) }