Use RemoteUrl instead of PreviewUrl and increase API timeout to 60 seconds
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// Setup config
|
// Setup config
|
||||||
config.Init()
|
config.Init()
|
||||||
|
|
||||||
|
|
||||||
// Initialize database
|
// Initialize database
|
||||||
database.Init()
|
database.Init()
|
||||||
@@ -26,7 +25,7 @@ func main() {
|
|||||||
|
|
||||||
runFetchPosts := func() {
|
runFetchPosts := func() {
|
||||||
// Get posts
|
// Get posts
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var posts []domain.Post = nil
|
var posts []domain.Post = nil
|
||||||
err, posts := services.PostServiceInstance.GetPostsFromApi(ctx, config.Config.Tag, config.Config.Instance)
|
err, posts := services.PostServiceInstance.GetPostsFromApi(ctx, config.Config.Tag, config.Config.Instance)
|
||||||
@@ -56,14 +55,14 @@ func main() {
|
|||||||
runFetchPosts()
|
runFetchPosts()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Run initial fetch on startup
|
// Run initial fetch on startup
|
||||||
go func() {
|
go func() {
|
||||||
runFetchPosts()
|
runFetchPosts()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// https://seefnasrul.medium.com/create-your-first-go-rest-api-with-jwt-authentication-in-gin-framework-dbe5bda72817
|
// https://seefnasrul.medium.com/create-your-first-go-rest-api-with-jwt-authentication-in-gin-framework-dbe5bda72817
|
||||||
|
|
||||||
r := server.SetupRouter()
|
r := server.SetupRouter()
|
||||||
err := r.Run(":8080")
|
err := r.Run(":8080")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -22,6 +22,6 @@ func (ps *EmbedCardHandler) GetEmbedCard(c *gin.Context) {
|
|||||||
post := ps.PostService.GetRandomPost()
|
post := ps.PostService.GetRandomPost()
|
||||||
c.HTML(200, "home/embed.html", gin.H{
|
c.HTML(200, "home/embed.html", gin.H{
|
||||||
"postUrl": post.Url,
|
"postUrl": post.Url,
|
||||||
"imageUrl": post.Attachments[0].PreviewUrl,
|
"imageUrl": post.Attachments[0].RemoteUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user