subscription.go 881 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2017 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 api // import "miniflux.app/api"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/response/json"
  8. "miniflux.app/reader/subscription"
  9. )
  10. // GetSubscriptions is the API handler to find subscriptions.
  11. func (c *Controller) GetSubscriptions(w http.ResponseWriter, r *http.Request) {
  12. subscriptionInfo, err := decodeURLPayload(r.Body)
  13. if err != nil {
  14. json.BadRequest(w, r, err)
  15. return
  16. }
  17. subscriptions, err := subscription.FindSubscriptions(
  18. subscriptionInfo.URL,
  19. subscriptionInfo.UserAgent,
  20. subscriptionInfo.Username,
  21. subscriptionInfo.Password,
  22. )
  23. if err != nil {
  24. json.ServerError(w, r, err)
  25. return
  26. }
  27. if subscriptions == nil {
  28. json.NotFound(w, r)
  29. return
  30. }
  31. json.OK(w, r, subscriptions)
  32. }