subscription.go 880 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. func (h *handler) getSubscriptions(w http.ResponseWriter, r *http.Request) {
  11. subscriptionInfo, bodyErr := decodeURLPayload(r.Body)
  12. if bodyErr != nil {
  13. json.BadRequest(w, r, bodyErr)
  14. return
  15. }
  16. subscriptions, finderErr := subscription.FindSubscriptions(
  17. subscriptionInfo.URL,
  18. subscriptionInfo.UserAgent,
  19. subscriptionInfo.Username,
  20. subscriptionInfo.Password,
  21. subscriptionInfo.FetchViaProxy,
  22. )
  23. if finderErr != nil {
  24. json.ServerError(w, r, finderErr)
  25. return
  26. }
  27. if subscriptions == nil {
  28. json.NotFound(w, r)
  29. return
  30. }
  31. json.OK(w, r, subscriptions)
  32. }