diff --git a/http.go b/http.go index 6d3927c..c05124a 100644 --- a/http.go +++ b/http.go @@ -19,21 +19,23 @@ func Serve() { hookHandler := func(w http.ResponseWriter, r *http.Request) { fmt.Println("Fetch feeds: ", time.Now().Format(time.RFC3339)) - for _, actor := range actors { - fmt.Println(actor.feed) - articles, err := allFeedItems(actor.feed) - if err != nil { - fmt.Println(actor.feed, err.Error()) - continue - } - // Post or update latest 5 article - for _, article := range (*articles)[0:int(math.Min(float64(len(*articles)-1), 4))] { - err = actor.PostArticle(article) + go func() { + for _, actor := range actors { + fmt.Println(actor.feed) + articles, err := allFeedItems(actor.feed) if err != nil { - fmt.Println("Posting", article, "failed") + fmt.Println(actor.feed, err.Error()) + continue + } + // Post or update latest 5 article + for _, article := range (*articles)[0:int(math.Min(float64(len(*articles)-1), 4))] { + err = actor.PostArticle(article) + if err != nil { + fmt.Println("Posting", article, "failed") + } } } - } + }() } webfingerHandler := func(w http.ResponseWriter, r *http.Request) {