31 lines
610 B
Go
31 lines
610 B
Go
|
package web
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/Jaculabilis/intake/core"
|
||
|
"github.com/Jaculabilis/intake/web/html"
|
||
|
)
|
||
|
|
||
|
func (env *Env) getChannel(writer http.ResponseWriter, req *http.Request) {
|
||
|
channel := req.PathValue("channel")
|
||
|
|
||
|
var items []core.Item
|
||
|
var err error
|
||
|
inactive := req.URL.Query().Get("inactive") == "1"
|
||
|
if inactive {
|
||
|
items, err = core.GetAllItemsForChannel(env.db, channel)
|
||
|
} else {
|
||
|
items, err = core.GetActiveItemsForChannel(env.db, channel)
|
||
|
}
|
||
|
if err != nil {
|
||
|
http.Error(writer, err.Error(), 500)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
data := html.FeedData{
|
||
|
Items: items,
|
||
|
}
|
||
|
html.Feed(writer, data)
|
||
|
}
|