entry_toggle_bookmark.go 839 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/json"
  10. "github.com/miniflux/miniflux/logger"
  11. )
  12. // ToggleBookmark handles Ajax request to toggle bookmark value.
  13. func (c *Controller) ToggleBookmark(w http.ResponseWriter, r *http.Request) {
  14. entryID, err := request.IntParam(r, "entryID")
  15. if err != nil {
  16. json.BadRequest(w, err)
  17. return
  18. }
  19. ctx := context.New(r)
  20. if err := c.store.ToggleBookmark(ctx.UserID(), entryID); err != nil {
  21. logger.Error("[Controller:ToggleBookmark] %v", err)
  22. json.ServerError(w, nil)
  23. return
  24. }
  25. json.OK(w, "OK")
  26. }