Added support for saving items

This commit is contained in:
2020-11-08 20:19:41 +00:00
parent 14176078ea
commit 9a25332ded
4 changed files with 65 additions and 1 deletions

View File

@@ -33,6 +33,10 @@ func (a *API) GetUnread(c *fiber.Ctx) error {
return c.JSON(a.FeedStore.GetUnread())
}
func (a *API) GetSaved(c *fiber.Ctx) error {
return c.JSON(a.FeedStore.GetSaved())
}
func (a *API) GetAll(c *fiber.Ctx) error {
return c.JSON(a.FeedStore.GetAll())
}
@@ -60,3 +64,8 @@ func (a *API) RefreshAll(c *fiber.Ctx) error {
return c.JSON(a.FeedStore.GetUnread())
}
func (a *API) SaveItem(c *fiber.Ctx) error {
a.FeedStore.ToggleSaved(c.Params("id"))
return nil
}

View File

@@ -51,7 +51,9 @@ func Start(port string) error {
app.Post("/api/feeds", api.PostFeed)
app.Get("/api/feed/:id", api.GetFeed)
app.Get("/api/item/:id", api.GetItem)
app.Post("/api/item/:id/save", api.SaveItem)
app.Get("/api/unread", api.GetUnread)
app.Get("/api/saved", api.GetSaved)
app.Get("/api/all", api.GetAll)
app.Post("/api/read/:id", api.PostRead)
app.Post("/api/read", api.PostReadAll)