jlelse
/
jsonpub
Archived
1
Fork 0

Only post latest article

This commit is contained in:
Jan-Lukas Else 2020-04-11 21:57:54 +02:00
parent 6edfd4e02b
commit c0594e4e04
1 changed files with 7 additions and 7 deletions

14
http.go
View File

@ -5,7 +5,6 @@ import (
"fmt"
"github.com/gorilla/mux"
"log"
"math"
"net/http"
"net/url"
"os"
@ -27,12 +26,13 @@ func Serve() {
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")
}
if len(*articles) < 1 {
fmt.Println(actor.feed, "Empty feed")
continue
}
err = actor.PostArticle((*articles)[0])
if err != nil {
fmt.Println("Posting", (*articles)[0], "failed")
}
}
}()