modify the RSS feed and sent it as XML

This commit is contained in:
Simon Rieger 2024-10-25 14:41:42 +02:00
parent 564bc640ef
commit 51a854d745

View file

@ -65,7 +65,7 @@ func convertICStoRSS(w http.ResponseWriter, r *http.Request) {
log.Println("[INFO] Generating RSS feed") log.Println("[INFO] Generating RSS feed")
// RSS als HTTP-Antwort senden // RSS als XML generieren
rssData, err := feed.ToRss() rssData, err := feed.ToRss()
if err != nil { if err != nil {
log.Printf("[ERROR] Unable to generate RSS feed: %v\n", err) log.Printf("[ERROR] Unable to generate RSS feed: %v\n", err)
@ -73,10 +73,14 @@ func convertICStoRSS(w http.ResponseWriter, r *http.Request) {
return return
} }
w.Header().Set("Content-Type", "application/rss+xml") // Header setzen für XML-Anzeige im Browser
w.Write([]byte(rssData)) w.Header().Set("Content-Type", "application/xml; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
log.Println("[INFO] RSS feed successfully generated and sent") // XML-Daten an den Browser senden
fmt.Fprint(w, rssData)
log.Println("[INFO] RSS feed successfully generated and sent as XML")
} }
func shouldIncludeEvent(event gocal.Event, timeRange string, now time.Time) bool { func shouldIncludeEvent(event gocal.Event, timeRange string, now time.Time) bool {