2025-01-25 05:27:26 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/Jaculabilis/intake/core"
|
|
|
|
"github.com/Jaculabilis/intake/web/html"
|
|
|
|
)
|
|
|
|
|
2025-01-28 00:38:02 +00:00
|
|
|
func (env *Env) getSource(writer http.ResponseWriter, req *http.Request) {
|
|
|
|
source := req.PathValue("source")
|
|
|
|
if source == "" {
|
|
|
|
http.NotFound(writer, req)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-01-25 05:27:26 +00:00
|
|
|
// TODO this needs to properly error if the source doesn't exist instead of just returning []
|
|
|
|
items, err := core.GetAllItemsForSource(env.db, source)
|
|
|
|
if err != nil {
|
|
|
|
http.NotFound(writer, req)
|
|
|
|
return
|
|
|
|
}
|
2025-01-25 05:41:46 +00:00
|
|
|
data := html.FeedData{
|
|
|
|
Items: items,
|
|
|
|
}
|
|
|
|
html.Feed(writer, data)
|
2025-01-25 05:27:26 +00:00
|
|
|
}
|