feed_remove.go 893 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/http/context"
  8. "github.com/miniflux/miniflux/http/request"
  9. "github.com/miniflux/miniflux/http/response"
  10. "github.com/miniflux/miniflux/http/response/html"
  11. "github.com/miniflux/miniflux/http/route"
  12. )
  13. // RemoveFeed deletes a subscription from the database and redirect to the list of feeds page.
  14. func (c *Controller) RemoveFeed(w http.ResponseWriter, r *http.Request) {
  15. feedID, err := request.IntParam(r, "feedID")
  16. if err != nil {
  17. html.ServerError(w, err)
  18. return
  19. }
  20. ctx := context.New(r)
  21. if err := c.store.RemoveFeed(ctx.UserID(), feedID); err != nil {
  22. html.ServerError(w, err)
  23. return
  24. }
  25. response.Redirect(w, r, route.Path(c.router, "feeds"))
  26. }