Support deleting feed
This commit is contained in:
@@ -33,6 +33,11 @@ func (fs *FeedStore) GetFeed(id string) *Feed {
|
||||
return feed
|
||||
}
|
||||
|
||||
func (fs *FeedStore) DeleteFeed(id string) {
|
||||
fs.getDB().Delete(Feed{ID: id})
|
||||
fs.getDB().Unscoped().Delete(Item{}, "feed_id = ?", id)
|
||||
}
|
||||
|
||||
func (fs *FeedStore) GetItem(id string) *Item {
|
||||
item := &Item{}
|
||||
fs.getDB().Where("id = ?", id).First(item)
|
||||
|
@@ -17,6 +17,11 @@ func (a *API) GetFeed(c *fiber.Ctx) error {
|
||||
return c.JSON(a.FeedStore.GetFeed(c.Params("id")))
|
||||
}
|
||||
|
||||
func (a *API) DeleteFeed(c *fiber.Ctx) error {
|
||||
a.FeedStore.DeleteFeed(c.Params("id"))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *API) PostFeed(c *fiber.Ctx) error {
|
||||
url := ""
|
||||
if err := c.BodyParser(&url); err != nil {
|
||||
|
@@ -50,6 +50,7 @@ func Start(port string) error {
|
||||
app.Get("/api/feeds", api.GetFeeds)
|
||||
app.Post("/api/feeds", api.PostFeed)
|
||||
app.Get("/api/feed/:id", api.GetFeed)
|
||||
app.Delete("/api/feed/:id", api.DeleteFeed)
|
||||
app.Get("/api/item/:id", api.GetItem)
|
||||
app.Post("/api/item/:id/save", api.SaveItem)
|
||||
app.Get("/api/unread", api.GetUnread)
|
||||
|
Reference in New Issue
Block a user