2024-08-03 20:05:08 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"log"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (ctx *ServerContext) HandleFeed(w http.ResponseWriter, req *http.Request) error {
|
|
|
|
ctx.WG.Add(1)
|
|
|
|
defer ctx.WG.Done()
|
|
|
|
name := req.URL.Path
|
|
|
|
name = name[len(name)-6:]
|
|
|
|
log.Println("requesting feed <", name, ">")
|
|
|
|
|
|
|
|
ctx.FeedCache.Lock()
|
|
|
|
defer ctx.FeedCache.Unlock()
|
|
|
|
if e, has := ctx.FeedCache.Texts[name]; has {
|
2024-08-15 02:53:02 +02:00
|
|
|
w.Header().Set("Content-Type", "application/rss+json")
|
2024-08-03 20:05:08 +02:00
|
|
|
fmt.Fprintf(w, e)
|
|
|
|
} else {
|
|
|
|
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|