From a0afd434718a74add5e6e6382400440668bd4538 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Sat, 11 Apr 2020 21:33:18 +0200 Subject: [PATCH] Fix --- http.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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) {