fixed weird xml string

This commit is contained in:
2022-05-08 19:55:32 -06:00
parent fa1b95a7dd
commit f2380057d6

View File

@@ -77,12 +77,11 @@ func (bc *BlogController) RSSFeed(c *gin.Context) {
c.HTML(http.StatusInternalServerError, "internal_server_error", &gin.H{}) c.HTML(http.StatusInternalServerError, "internal_server_error", &gin.H{})
return return
} }
c.Header("Content-Type", "text/xml")
var rawXml bytes.Buffer var rawXml bytes.Buffer
err = t.Execute(&rawXml, posts) err = t.Execute(&rawXml, posts)
if err != nil { if err != nil {
c.HTML(http.StatusInternalServerError, "internal_server_error", &gin.H{}) c.HTML(http.StatusInternalServerError, "internal_server_error", &gin.H{})
return return
} }
c.String(http.StatusOK, strings.Replace(rawXml.String(), "&", "&", -1), &gin.H{}) c.Data(http.StatusOK, "text/xml", []byte(strings.Replace("&", "&", rawXml.String(), -1)))
} }