Point Subdomain to Golang Gin

87 Views Asked by At

I've wrote a gin code, so I'm trying to point a subdomain so that when I run the https request on the link, I be able to get the data that I'm expecting. the subdomain is good and live, and I've pointed it to my server's ip address. but when I run my code, the code runs but I still can't access it throught the subdomain. Anyone help me out please.

    r.GET("/getgossips", func(c *gin.Context) {
    var notices []Gossip_Posts

    // Retrieve all posts from the database
    if err := myDB.Order("created_at desc").Find(&notices).Error; err != nil {
        c.JSON(500, gin.H{"error": "Failed to retrieve notices"})
        return
    }

    // Create an array to store the posts in JSON format
    noticeArray := make([]gin.H, len(notices))
    for i, post := range notices {
        noticeArray[i] = gin.H{
            "id":      post.ID,
            "title":   post.Title,
            "content": post.Content,
            "media":   gossipbaseURL + post.Media,
            "email":   post.User_email,
            "likes":   post.Likes,
        }
    }

    // Return the posts as an array in JSON
    c.JSON(200, noticeArray)
})

r.Run(":8080")
0

There are 0 best solutions below