intake/web/source.go

23 lines
519 B
Go
Raw Normal View History

package web
import (
"net/http"
"github.com/Jaculabilis/intake/core"
"github.com/Jaculabilis/intake/web/html"
)
func (env *Env) sourceHandler(writer http.ResponseWriter, req *http.Request) {
source := req.URL.Path[len("/source/"):]
// 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
}
data := html.FeedData{
Items: items,
}
html.Feed(writer, data)
}